|
In this code example, we assume Add Record page is not created by default. If you already have Add Record
page in your application, you can either delete or modify Add Record page in similar fashion.
Step 1: Create an Add Record page using the New Page dialog or Application Wizard in Iron Speed Designer. For this example, use the Customers table in the Northwind database.
Step 2: Click "Configure..." in the Record panel to display the Record Panel Wizard. In the Fields tab, remove all of the fields except CustomerID, CompanyName, ConctactName, and ContactTitle. Then click "Finish".
Step 3: Drag and drop a button from the tool box within the Add Record panel. Set the button text to "Next".
Step 4: Double click the "Next" button to display the Properties dialog box for the button. On the Bindings tab, set these properties:
| Property |
Setting |
| Button Command |
Redirect |
| Action after command |
Go to a specific URL Specify the path of the second page as the URL., which will be created in the second part of this code example. You can come back and set this URL after the page is created. |
On the Attributes tab, set these properties:
| Property |
Setting |
| Button-CausesValidation |
True This ensures the data on the first page will be validated before the second page is displayed. |
Step 6: Override the Button_Click() method in the AddCustomerPage class in the first page, located in:
.NET Framework 1.1 and 2.0:
|
...\<App Folder>\Customers\AddCustomersPage.aspx.cs or .vb
|
Handle the command for the button as shown below. In this function, the data values are stored
in session variables.
C#:
public void Button_Click(object sender, EventArgs args)
{
//store data in session variables
System.Web.HttpContext.Current.Session["Customer"] = this.CustomerID.Text;
System.Web.HttpContext.Current.Session["CompanyName"] = this.CompanyName.Text;
System.Web.HttpContext.Current.Session["ContactName"] = this.ContactName.Text;
System.Web.HttpContext.Current.Session["ContactTitle"] = this.ContactTitle.Text;
Button_Click_Base(sender, args);
}
|
Visual Basic .NET:
Public Sub Button_Click(ByVal sender As Object, ByVal args As EventArgs)
System.Web.HttpContext.Current.Session("Customer") = Me.CustomerID.Text
System.Web.HttpContext.Current.Session("CompanyName") = Me.CompanyName.Text
System.Web.HttpContext.Current.Session("ContactName") = Me.ContactName.Text
System.Web.HttpContext.Current.Session("ContactTitle") = Me.ContactTitle.Text
Button_Click_Base(sender, args)
End Sub
|
|