Using the RecordControl Class in Iron Speed Designer


The RecordControl class has several events that set values in the control or call custom logic before a record is saved in the database.
- Pooja Daga, Technical Support Engineer, Iron Speed, Inc.

May 24, 2006

The RecordControl Class

In your generated application, the pages’ customizable code-behind files contain two additional classes in addition to the customizable class for the page itself.
  • <Table>TableControl
  • <Table>TableControlRecordControl
The RecordControl class has several events that set values in the control or call custom logic before a record is saved in the database. Several events that can be handled in the RecordControl class are illustrated below.

PostSetUIData

To set the initial value of a control, handle the PostSetUIData event in the RecordControl class. The example below sets the initial value of the ShipCountry FieldValue control in an AddOrdersPage class.

Visual Basic .NET:

Private Sub RecordControl_PostSetUIData(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PostSetUIData
    Me.ShipCity.Text = "San Jose"
End Sub

Note: The PostSetUIData event is not implemented for C# in Iron Speed Designer V3.2 (.NET Framework 1.1 and .NET Framework 2.0).

PostGetUIData

To change values before they are saved, handle the PostGetUIData event in the RecordControl class. The example below sets the value of the ShipCity field in the PostGetUIData event in the OrdersRecordControl class of an Add Orders page.

C#:

public OrdersRecordControl()
{
    this.Load +=new EventHandler(RecordControl_PostGetUIData_EventHookup);
}
private void RecordControl_PostGetUIData(object sender, EventArgs e)
{
    OrdersRecord myrec = this.GetRecord(true);
    myrec.ShipCity = "SunnyVale";
}

Visual Basic .NET:

Private Sub RecordControl_PostGetUIData(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PostGetUIData
 
    Dim myrec As OrdersRecord = Me.GetRecord(True)
    myrec.ShipCity = "SunnyVale"
End Sub

PreRender

To initialize, format or compute a value; hide or display a control based on some criteria; or change the look and feel of a control, handle the PreRender event for the RecordControl class. The example below converts the text of the ShipCountry FieldValue control to uppercase in a Show Orders Table page by handling the PreRender event of the OrdersTableControlRecordControl class.

C#:

public OrdersTableControlRecordControl()
{
    this.PreRender += new EventHandler(RecordControl_PreRender);
}
private void RecordControl_PreRender(object sender, EventArgs e)
{
    string tempStr = this.ShipCountry.Text;
    this.ShipCountry.Text = tempStr.ToUpper();
}

Visual Basic .NET:

Private Sub RecordControl_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
    Dim tempStr As String = Me.ShipCountry.Text
    Me.ShipCountry.Text = tempStr.ToUpper
End Sub

Note: you can use the Code Telescope to add the above events to your pages' code-behind files.

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