源代碼如下:
<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 屬性