<%@ Page Language="VB" %>
<script runat="server">
Sub Button1_OnClick(sender As Object, e As EventArgs)
Dim numrows As Integer
Dim numcells As Integer
Dim i As Integer = 0
Dim j As Integer = 0
Dim Row As Integer = 0
Dim r As HtmlTableRow
Dim c As HtmlTableCell
' Generate rows and cells
numrows = CInt(Select1.Value)
numcells = CInt(Select2.Value)
For j = 0 To numrows-1
r = new HtmlTableRow()
If (row Mod 2 <> 0) Then
r.BgColor = "Gainsboro"
End If
row += 1
For i = 0 To numcells-1
c = new HtmlTableCell()
c.Controls.Add(new LiteralControl("row " & j & ", cell " & i))
r.Cells.Add(c)
Next i
Table1.Rows.Add(r)
Next j
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
Table rows:
<select id="Select1" runat="server">
<option Value="1">1</option>
<option Value="2">2</option>
<option Value="3">3</option>
<option Value="4">4</option>
<option Value="5">5</option>
</select>
Table cells:
<select id="Select2" runat="server">
<option Value="1">1</option>
<option Value="2">2</option>
<option Value="3">3</option>
<option Value="4">4</option>
<option Value="5">5</option>
</select>
<input id="Button1" type="button" OnServerClick="Button1_OnClick" value="Button" runat="server" />
<hr />
<table id="Table1" CellPadding="5" CellSpacing="0" Border="1" runat="server" />
</form>
</body>
</html>