|
In the example below, when a user attempts to add a new Order in an Add Record page without specifying the ShipPostalCode value and clicks the “Save” button, the Order is not saved and, instead, the user is redirected back to the previous page (typically the Show Orders Table page). Add this code customization to the AddOrderPage class, located in:
.NET Framework 1.1 and 2.0:
|
...\<App Folder>\Orders\AddOrdersPage.aspx.cs or .vb
|
C#:
public void SaveButton_Click(object sender, EventArgs args)
{
if (this.ShipPostalCode.Text == "")
{
this.RedirectBack();
}
SaveButton_Click_Base(sender, args);
}
|
Visual Basic .NET
Public Sub SaveButton_Click(ByVal sender As Object, ByVal args As EventArgs)
If (Me.ShipPostalCode.Text = "") Then
Me.RedirectBack
End If
SaveButton_Click_Base(sender, args)
End Sub
|
Important: If the button is set to redirect to another page in the Page Properties dialog’s Bindings
tab, then calling the base click method will redirect to this page and any code placed after the call to
the base click method will not be executed.
In the example below, a new button called “Fill Default Value” has been added to an Add Record page.
When the button is clicked, a default value of “99999” is inserted into the ShipPostalCode text box field.
Step 1: Add a button from Iron Speed Designer toolbox, and place it next to the Cancel button.
Step 2: Double-click the new button control to display the Properties dialog. In the Display tab, enter “Fill Default Value” for the Button Text, and select “Custom” for the Button Command.
Step 3: Add the following code in the AddOrdersPage class, located in:
.NET Framework 1.1 and 2.0:
|
...<App Folder>\Orders\AddOrdersPage.aspx.cs or .vb
|
C#:
public void Button_Click(object sender, EventArgs args)
{
Button_Click_Base(sender, args);
this.ShipPostalCode.Text = "99999";
}
|
Visual Basic .NET
Public Sub Button_Click(ByVal sender As Object, ByVal args As EventArgs)
Button_Click_Base(sender, args)
Me.ShipPostalCode.Text = "99999"
End Sub
|
|