|
In some cases it may be desirable to pass calculated values via a page’s URL. For example, you might
wish to pass the grand total of a table column to another page:
|
http://MyApp/Page.aspx?Total= FreightGrandTotal.Text()
|
Or you might wish to pass the value of a dynamically retrieved session variable to a page:
|
http://MyApp/Page.aspx?Value=Session("Test")
|
You can do this with a code customization that overrides the ModifyRedirectUrl() method in the Table class.
In the example below, the UnitPriceGrandTotal for the Products table is passed as a URL parameter when
the "New" button is clicked on the ShowProductsTablePage.aspx page. To place the UnitPriceGrandTotal in
the URL, click the Configure... button on the Products table panel, select the Totals tab on the Table Panel
Wizard and select UnitPrice. Then, override the ModifyRedirectUrl method in the Table class of the
ShowProductsTablePage.aspx page.
For .NET Framework 1.1, add a code customization to the Table class of the ShowProductsTablePage.aspx.cs, located in:
|
...\<AppFolder>\<Table Name>\ShowProductsTablePage.aspx.cs
|
C#:
public override void ModifyRedirectUrl(BaseClasses.ApplicationEventArgs args)
{
base.ModifyRedirectUrl(args);
UserControl newButton = ((UserControl)(args.EventSource));
If (newButton.ID == "ProductsNewButton")
{
string urlStr = args.RedirectUrl;
this.Page.Response.Redirect(urlStr + "?Total=" + UnitPriceGrandTotal.Text);
}
}
|
Note: Make sure you call the base.ModifyRedirectUrl method.
Visual Basic .NET:
Public Overrides Sub ModifyRedirectUrl(ByVal args As BaseClasses.ApplicationEventArgs)
MyBase.ModifyRedirectUrl(args)
Dim newButton As UserControl = CType(args.EventSource, UserControl)
If newButton.ID = "ProductsNewButton" Then
Dim urlStr As String = args.RedirectUrl
Me.Page.Response.Redirect(urlStr & "?Total=" & UnitPriceGrandTotal.Text)
End If
End Sub
|
Note: Make sure you call the MyBase.ModifyRedirectUrl method.
For .NET Framework 2.0, add a code customization to the Table class of ShowProductsTablePage.Controls.cs,
located in:
|
...\<AppFolder>\App_Code\<Table Name>\ShowProductsTablePage.Controls.cs
|
C#:
public override void ModifyRedirectUrl(BaseClasses.ApplicationEventArgs args)
{
base.ModifyRedirectUrl(args);
System.Web.UI.UserControl newButton = ((System.Web.UI.UserControl)(args.EventSource));
if(newButton.ID == "ProductsNewButton")
{
string urlStr = args.RedirectUrl;
this.Page.Response.Redirect(urlStr + "?Total=" + UnitPriceGrandTotal.Text);
}
}
|
Visual Basic .NET:
Public Overrides Sub ModifyRedirectUrl(ByVal args As BaseClasses.ApplicationEventArgs)
MyBase.ModifyRedirectUrl(args)
Dim newButton As UserControl = CType(args.EventSource, UserControl)
If newButton.ID = "ProductsNewButton" Then
Dim urlStr As String = args.RedirectUrl
Me.Page.Response.Redirect(urlStr & "?Total=" & UnitPriceGrandTotal.Text)
End If
End Sub
|
|