Pass Calculated Values in URL's
In some cases it may be desirable to pass calculated values via a page's URL. You can do this with a code customization that overrides the ModifyRedirectUrl() method in the Table class. Learn how this works.
- Pooja Daga, Technical Support Engineer, Iron Speed, Inc.

March 22, 2006
Iron Speed Designer V3.2

Procedure
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

About the Author
Pooja Daga
Technical Support Engineer, Iron Speed, Inc.

Pooja has experience developing Web applications using .NET technology. She started her career with PCS, a leading software services company headquartered in India and has been with Iron Speed since 2005.

Pooja holds an M.S. degree in Computer Application and a B.S. degree in Electrical engineering from Maharaja Sayajirao University in India.



  Privacy Statement