源代码如下:
<script runat="server">Sub submit(sender As Object, e As EventArgs)
Dim row,numrows,numcells,j,i
row=0
numrows=cint(rows1.Value)
numcells=cint(cells1.Value)
for j=1 to numrows
Dim r As New HtmlTableRow()
row=row+1
for i=1 to numcells
Dim c As New HtmlTableCell()
c.Controls.Add(New LiteralControl("row " & j & ", cell " & i))
r.Cells.Add(c)
next
t1.Rows.Add(r)
t1.Visible=true
next
End Sub
</script>
<!DOCTYPE html>
<html>
<body>
<form runat="server">
<p>Table rows:
<select id="rows1" runat="server">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<br>Table cells:
<select id="cells1" runat="server">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<br><br>
<input type="submit" value="Display Table" runat="server" OnServerClick="submit">
</p>
<table id="t1" border="1" runat="server" visible="false"/>
</form>
</body>
</html>
运行结果:
- ASP.NET 教程
- ASP.NET Web Pages WebSecurity 参考手册
- ASP.NET Razor C# 变量
- ASP.NET MVC 文件夹
- ASP.NET CheckBoxList 控件
- WebSecurity HasUserId 属性
- WebSecurity GetCreateDate 方法
- HTML Table 2
- ASP.NET HTML 控件 Textbox 2
- C# 实例 If Else 条件
- C# 实例 使用 Chart 帮助器 根据数组显示条形图
- htmlimage
- htmlimage 2
- ASP.NET Calendar ShowTitle 属性
- ASP.NET Calendar TodayDayStyle 属性
- ASP.NET Button ValidationGroup 属性
- ASP.NET HyperLink Text 属性
- ASP.NET Image AlternateText 属性
- ASP.NET RadioButtonList RepeatColumns 属性
- ASP.NET TableCell RowSpan 属性