Updated June 5, 2006
Iron Speed Designer V3.2 and V4.0
Iron Speed Designer generates standard ASP.NET controls in the ASPX pages. These controls are generated from the GEN: code generation tags in the HTML files. The code generation tags allow the binding of data to the ASPX controls generated in the ASPX page. Sometimes, however, you just want to display text on a page, place a label adjacent to a textbox or display other data that is not necessarily coming from a database field. In such cases, you can add standard ASPX controls by dragging them from the Iron Speed Designer tool box on to a web page in your application.
Follow these steps to access ASPX controls in code-behind classes generated by Iron Speed Designer.
Step 1: Create an application using a table, such as the Orders table in Northwind.
Step 2: Drag and drop an ASPX textbox on the ShowOrdersTablePage from the Iron Speed Designer tool box. In this example, the ASPX text box is not within the Table control. Iron Speed Designer adds this HTML to the HTML layout page.
<asp:textbox id="myTextbox" runat="server" /></td>
Step 3: Handle the PreRender event for the ShowOrdersTablePage and set the text of the ASPX text box. This is described in detail in the following sections.
Add your code in the “Page” class of ShowOrdersTablePage.aspx.cs, located in:
...\<Application Folder>\Orders\ShowOrdersTablePage.aspx.cs
C#:
public ShowOrdersTablePage()
{
this.PreRender += new EventHandler(Page_PreRender);
}
private void Page_PreRender(object sender, EventArgs e)
{
this.myTextbox.Text = "PAGE CLASS";
}
Visual Basic .NET:
Private Sub ShowOrdersTablePage_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
Me.myTextbox.Text = "PAGE CLASS"
End Sub
Add your code in the TableControl class or RecordControl class of ShowOrdersTablePage.aspx.cs, located in:
...\<Application Folder>\App_Code\Orders\ShowOrdersTablePage.Controls.cs
C# TableControl class:
public OrdersTableControl()
{
this.PreRender += new EventHandler(TableControl_PreRender);
}
private void TableControl_PreRender(object sender, EventArgs e)
{
System.Web.UI.WebControls.TextBox myTextbox =
(System.Web.UI.WebControls.TextBox)(this.Page.FindControlRecursively("myTextbox"));
myTextbox.Text = "TABLE CONTROL CLASS";
}
C# RecordControl class:
public OrdersTableControlRecordControl()
{
this.PreRender += new EventHandler(RecordControl_PreRender);
}
private void RecordControl_PreRender(object sender, EventArgs e)
{
System.Web.UI.WebControls.TextBox myTextbox =
(System.Web.UI.WebControls.TextBox)(this.Page.FindControlRecursively("myTextbox"));
myTextbox.Text = "RECORD CONTROL CLASS";
}
Visual Basic .NET TableControl and RecordControl classes:
Private Sub myOrdersTableControlRecordControl_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.PreRender
Dim tempTextBox As System.Web.UI.WebControls.TextBox =
CType(Me.Page.FindControlRecursively("myTextBox"),
System.Web.UI.WebControls.TextBox)
tempTextBox.Text = "TABLE CONTROL AND RECORD CONTROL CLASS"
End Sub
Note that “myTextBox” is the ID of the ASPX Textbox.