| phil 的个人资料Phil Harvey's .NET Space日志列表 | 帮助 |
|
|
5月16日 Talking about Article: Integrating an ASP.NET e-commerce system with PayPal's Instant Payment Notification (IPN)This article demonstrates how to validate PayPal IPN requests in asp.net. My only comment is once you have received the validation response from PayPal you need to check it equals "VERIFIED". Otherwise, it might have returned "INVALID", which probably means someones messing about you. Quote Article: Integrating an ASP.NET e-commerce system with PayPal's Instant Payment Notification (IPN) 1月5日 Get the remote callers IP address in a web methodFor the purpose of logging, auditing and extra security is can be very useful to know the remote parties IP address when a web method is called in a .NET Web Service. The remote address can be obtained from the UserHostAddress property of the HttpRequest object. This is accessible via the HttpContext object, which is available as a base property of any WebService class. In any web method just call Me.Context.Request.UserHostAddress. A web method to echo the remote callers IP address Imports System.Web.Services 1月4日 User friendly forms in ASP.NETMany web pages contain a very simple form containing just a text box and a button. For example Google's front page. When a user encounters such a simple form, they expect to be able to quickly make an entry and submit the form. The user certainly does not want to click or tab into the textbox, type, then click the button with the mouse. They want to type and press enter. Implementing this type of functionality in ASP.NET is not entirely obvious. The trick is to use the TextChanged event on the textbox. The name of this event is misleading, because it will only postback when the user presses the enter key while the textbox has focus. You will want pressing enter or clicking the button to perform the same action, so make your code look something like the following and you'll be sorted. Submit a form with a button click or an enter key press Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click You may also want to give default focus to the textbox when the page loads so the user can type straight away. Add a property similar to the following to the body tag of the ASP.NET page. Give default focus to a textbox on an ASP.NET page <body onload="document.Form1.txtCriteria.focus()"> 12月5日 Force page structure with inheritanceI've been doing a fair bit of ASP.NET work lately. I like ASP.NET but I have issues with the Visual Studio IDE so I prefer to build my sites at runtime, adding structure and components via code. The fine details of what the page actually looks like can be dictated via CSS style sheets. As a design methodology it works as long as your code structure makes sense. A good object-orientated structure goes a long way. One of the techniques you can employ using this method is page inheritance in order to enforce a standard page structure throughout your entire site. In this example I will show how to use page inheritance to display a standard header and footer on every page. Firstly you need to make a base class which draws the page structure and overwrites some methods to enforce the structure. Public MustInherit Class BasePageInherits System.Web.UI.Page ' The page body goes into this table cell. Private _pageBodyCell As New TableCell() ' Override the Controls property so it returns ' the page body table cell. Public Overrides ReadOnly Property Controls() As ControlCollection Get Return Me._pageBodyCell.Controls End Get End Property ' Use constructer to draw the page structure. Sub New() ' The page table structure. Dim pageTable As New Table() ' Create page header. pageTable.CssClass = "pageTable" Dim pageHeaderRow As New TableRow() pageTable.Controls.Add(pageHeaderRow) Dim pageHeaderCell As New TableCell() pageHeaderCell.CssClass = "headerCell" pageHeaderRow.Controls.Add(pageHeaderCell) ' Draw page header. Me.drawPageHeader(pageHeaderCell) ' Create page body. Dim pageBodyRow As New TableRow() pageTable.Controls.Add(pageBodyRow) _pageBodyCell.CssClass = "bodyCell" pageBodyRow.Controls.Add(_pageBodyCell) ' Create page footer. Dim pageFooterRow As New TableRow() pageTable.Controls.Add(pageFooterRow) Dim pageFooterCell As New TableCell() pageFooterCell.CssClass = "footerCell" pageFooterRow.Controls.Add(pageFooterCell) ' Draw page footer. Me.drawPageFooter(pageFooterCell) ' Add table to page. MyBase.Controls.Add(pageTable) End Sub Private Sub drawPageHeader(ByVal header As TableCell) Dim headerLabel As New Label() headerLabel.Text = "My ASP.NET Website" headerLabel.CssClass = "headerLabel" header.Controls.Add(headerLabel) End Sub Private Sub drawPageFooter(ByVal footer As TableCell) Dim footerLabel As New Label() footerLabel.Text = "Copyright etc" footerLabel.CssClass = "footerLabel" footer.Controls.Add(footerLabel) End Sub End Class For each web form you create make it inherit BasePage and the structure will be applied to it. Public Class MyPage |
|
|