E
Epetruk
Hi all,
I'm trying to write a simple page where a table's properties and contained
controls are generated dynamically.
I have the following code:
In Test.aspx:
<%@ Page language="c#" Codebehind="Test.aspx.cs" AutoEventWireup="false"
Inherits="Test.TestForm" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Test</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="TestForm" method="post" runat="server">
<table id="TestTable" runat="server">
</table>
</form>
</body>
</HTML>
In test.aspx.cs:
public class TestForm : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
TestTable = new HtmlTable();
TestTable.Width = "100%";
HtmlTableRow rw = new HtmlTableRow();
HtmlTableCell cl = new HtmlTableCell();
cl.InnerText = "Test";
rw.Cells.Add(cl);
TestTable.Rows.Add(rw);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
protected System.Web.UI.HtmlControls.HtmlTable TestTable;
}
Like I said, very simple.
However, when I run the code, nothing shows up - I would expect to see a
single cell with 'Test' displayed in it.
Can anyone explain what's going on here?
TIA,
I'm trying to write a simple page where a table's properties and contained
controls are generated dynamically.
I have the following code:
In Test.aspx:
<%@ Page language="c#" Codebehind="Test.aspx.cs" AutoEventWireup="false"
Inherits="Test.TestForm" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Test</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="TestForm" method="post" runat="server">
<table id="TestTable" runat="server">
</table>
</form>
</body>
</HTML>
In test.aspx.cs:
public class TestForm : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
TestTable = new HtmlTable();
TestTable.Width = "100%";
HtmlTableRow rw = new HtmlTableRow();
HtmlTableCell cl = new HtmlTableCell();
cl.InnerText = "Test";
rw.Cells.Add(cl);
TestTable.Rows.Add(rw);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
protected System.Web.UI.HtmlControls.HtmlTable TestTable;
}
Like I said, very simple.
However, when I run the code, nothing shows up - I would expect to see a
single cell with 'Test' displayed in it.
Can anyone explain what's going on here?
TIA,