执行。submit子程序将根据用户的输入来生成表格。本信息代表文章来源网页教学webjx.com请大家去www.webjx.com浏览!
<script runat="server"> Sub submit(sender As Object, e As EventArgs) Dim row,numrows,numcells,j,i row=0 numrows=rows1.Value numcells=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>
<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>
|
2、在此示例中我们在一个.aspx文件中声明一个HtmlTable控件及一个HtmlInputButton控件(要记住把控件嵌入HtmlForm控件中)。当提交按钮被触发的时候,submit子程序被执行。submit子程序将修改表格的背景色和边框色,同时改变单元格中的内容。看到此信息请您谅解!webjx.com为了防采集加上的!请到网页教学网浏览更多信息。
<script runat="server"> Sub submit(sender As Object, e As EventArgs) dim i,j table1.BGColor="yellow" table1.BorderColor="red" for i=0 To table1.Rows.Count-1 for j=0 To table1.Rows(i).Cells.Count-1 table1.Rows(i).Cells(j).InnerHtml="Row " & i next next End Sub </script>
<html> <body>
<form runat="server"> <table id="table1" border="1" runat="server"> <tr> <td>Cell 1</td> <td>Cell 2</td> </tr> <tr> <td>Cell 3</td> <td>Cell 4</td> </tr> </table> <br /> <input type="button" value="Change Contents" OnServerClick="submit" runat="server"/> </form>
</body> </html>
|
|