动态表走出去的形式标记 [英] Dynamic table going out of the form tag
本文介绍了动态表走出去的形式标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在页面加载添加动态表如下:
I have added a dynamic table on page load as follows
protected void Page_Load(object sender, EventArgs e)
{
Table tbl = new Table();
tbl.ID = "table1";
this.Controls.Add(tbl);
for (int row = 0; row < 5; row++)
{
TableRow rw = new TableRow();
TableCell cell = new TableCell();
Label text = new Label();
text.Text = "text";
cell.Controls.Add(text);
rw.Cells.Add(cell);
tbl.Controls.Add(rw);
}
}
问题是,当我检查浏览器中的元素,则该表出现出来表单标签如下:
The problem is, when I inspect the elements in the browser, the table appears to come out of the form tag as follows.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body onload="return TimerStart();">
<form name="aspnetForm" method="post" action="trial2.aspx" id="aspnetForm">
</form>
</body>
</html>
<table id="table1" border="0">
<tr>
<td><span>text</span></td>
</tr><tr>
<td><span>text</span></td>
</tr><tr>
<td><span>text</span></td>
</tr><tr>
<td><span>text</span></td>
</tr><tr>
<td><span>text</span></td>
</tr>
</table>
我想表单标签内的表,请帮帮忙!
I want the table within the form tag, Please help!
推荐答案
在添加您的表格&LT; / HTML&GT;
标签
在ASP.Net更好您在形式上与标签添加低于code
In ASP.Net better you add it with in form tag with below code
this.Form.Controls.Add(tbl);
而不是 this.Controls.Add(TBL);
这篇关于动态表走出去的形式标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文