.Append(" var sTable=document.createElement(\"table\"); ").Append(Environment.NewLine)//****************表格
.Append(" sTable.style.margin=\"1em 0\" ").Append(Environment.NewLine)
.Append(" sTable.setAttribute(\"id\",\"sTable1\"); ").Append(Environment.NewLine)
.Append(" var sTr1 = sTable.insertRow(); ").Append(Environment.NewLine) ///////////////////////
.Append(" var sTd11 = sTr1.insertCell(); ").Append(Environment.NewLine)
.Append(" sTd11.innerHTML=\"专辑简介:\"; ").Append(Environment.NewLine)
.Append(" var sTd12 = sTr1.insertCell(); ").Append(Environment.NewLine)
.Append(" sTd12.innerHTML=\"<asp:TextBox ID=\"TextBox1\" runat=\"server\" Height=\"21px\" Width=\"232px\" > <\\asp:TextBox > ; ").Append(Environment.NewLine)
.Append(" var sTr2 = sTable.insertRow(); ").Append(Environment.NewLine)
.Append(" var sTd21 = sTr2.insertCell(); ").Append(Environment.NewLine)
.Append(" sTd21.innerHTML=\"专辑简介:\"; ").Append(Environment.NewLine)
.Append(" var sTd22 = sTr2.insertCell(); ").Append(Environment.NewLine)
.Append(" sTd22.innerHTML=\"<asp:TextBox ID=\"TextBox2\" runat=\"server\" Height=\"120px\" Width=\"232px\" TextMode=\"MultiLine\" > <\\asp:TextBox > ; ").Append(Environment.NewLine)
.Append(" document.getElementById(\"msgDiv\").appendChild(sTable); ").Append(Environment.NewLine)请问下这样的代码生成一个表格:
<table>
<tr>
<td>专辑名称:</td>
<td><asp:TextBox ID="TextBox1" runat="server" Height="21px" Width="232px"></asp:TextBox></td>
</tr>
<tr>
<td style="padding-bottom:80px">专辑简介:</td>
<td><asp:TextBox ID="TextBox2" runat="server" Height="120px" Width="232px" TextMode="MultiLine"></asp:TextBox></td>
</tr>
</table>
有什么问题?现在是本来在后台有个函数可以生成Html代码的(CSS+ js),我加了上面的代码后就什么也不显示了,不知道问题出现在哪?
asp:TextBox ID="TextBox2" runat="server" 这些 东西 ,浏览器不认识你自己右键查看源代码,不就知道是这么回事了
它最终会被浏览器解释成<input>标签
所以sTd12.innerHTML=\"<input type=\"text\" id=\"text1\" style=\"height:21px; width:232px\" > <")
.Append(" sTd11.innerHTML=\"专辑名称:\"; ").Append(Environment.NewLine)
.Append(" var sTd12 = sTr1.insertCell(); ").Append(Environment.NewLine)
.Append(" sTd12.innerHTML=\"<input type=\"text\" id=\"text1\" runat=\"server\" style=\"height:21px; width:232px\" \\ > \"; ").Append(Environment.NewLine)
.Append(" var sTr2 = sTable.insertRow(); ").Append(Environment.NewLine)
.Append(" var sTd21 = sTr2.insertCell(); ").Append(Environment.NewLine)
.Append(" sTd21.innerHTML=\"专辑简介:\"; ").Append(Environment.NewLine)
.Append(" var sTd22 = sTr2.insertCell(); ").Append(Environment.NewLine)
.Append(" sTd22.innerHTML=\"<input type=\"text\" id=\"text2\" runat=\"server\" style=\"height:120px; width:232px\" \\ > \"; ").Append(Environment.NewLine)这里的添加文本框不可以,如果去掉则可以显示
var sTd11 = sTr1.insertCell();
sTd11.innerHTML="专辑名称:";
var sTd12 = sTr1.insertCell();
sTd12.innerHTML="<input type="text" id="text1" runat="server" style="height:21px; width:232px" \ > ";
var sTr2 = sTable.insertRow();
var sTd21 = sTr2.insertCell();
sTd21.innerHTML="专辑简介:";
var sTd22 = sTr2.insertCell();
sTd22.innerHTML="<input type="text" id="text2" runat="server" style="height:120px; width:232px" \ > ";