Prev | Current Page 108 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"

NET 57
for (int x = 0; x < xDim; x++)
{
// create
cell = new HtmlTableCell();
cell.Attributes.Add("border", "1");
// create a
content = new HtmlGenericControl("SPAN");
content.InnerHtml = "X:" + x.ToString() +
"Y:" + y.ToString();
cell.Controls.Add(content);
row.Cells.Add(cell);
}
Table1.Rows.Add(row);
}
}
}
}
In this example, the .ascx page is a mix of HTML content and server controls. The two
Label controls come from the System.Web.UI.WebControls namespace. The labels display the X
and Y properties??™ configuration of the user control:
X:;
Y:
The HtmlTable control comes from the System.Web.UI.HtmlControls namespace and is
declared as a table with a border size of 1 on the .ascx page.
The table control in the HtmlControl namespace was chosen over the table in the WebControl
namespace, because it does not automatically add styling information to the final output. This
is desirable at this point in the book; we defer the control styling discussion until Chapter 4.
The code-behind class file of the user control is much more interesting in this example,
because it contains the content-building code.


Pages:
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120