The SimpleControls Code-Behind Class File
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
namespace ControlsBook2Web.Ch01
{
public partial class SimpleControls : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
CHAPTER 1 ?– SERVER CONTROL BASICS 23
protected void BuildTableButton_Click(object sender, EventArgs e)
{
int xDim = Convert.ToInt32(XTextBox.Text);
int yDim = Convert.ToInt32(YTextBox.Text);
BuildTable(xDim, yDim);
}
private void BuildTable(int xDim, int yDim)
{
Table table;
TableRow row;
TableCell cell;
Literal content;
table = new Table();
table.BorderWidth = 1;
table.BorderStyle = BorderStyle.Ridge;
for (int y = 0; y < yDim; y++)
{
row = new TableRow();
for (int x = 0; x < xDim; x++)
{
cell = new TableCell();
cell.BackColor = Color.Blue;
cell.BorderWidth = 1;
cell.ForeColor = Color.Yellow;
cell.Font.Name = "Verdana";
cell.Font.Size = 16;
cell.Font.Bold = true;
cell.Font.Italic = true;
content = new Literal();
content.Text = "
X:" + x.ToString() +
"Y:" + y.ToString() + "";
cell.Controls.Add(content);
row.Cells.Add(cell);
}
table.Rows.Add(row);
}
TablePlaceHolder.Controls.
Pages:
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75