|
想点击Mon动态添加4个控件,原先放在.cs中写,发现postback后会消失,所以放在html中写。现在希望点击button2后能获得text0,text1,text3的值,但是一旦把str += "<input id=id"+inputNum+" type=text name=text"+inputNum+">"; 变成str += "<input id=id"+inputNum+" type=text runat=server name=text"+inputNum+">"; 后就出错。请问要是不加runat=server,可否在.cs中得到text0.value?
<script>
var inputNum = 0;
function create()
{
var str = "";
str += "<input id=id"+inputNum+" type=text name=text"+inputNum+">";
inputNum++;
str += "<input type=text name=text"+inputNum+">";
inputNum++;
str += "<input type=radio name=text"+inputNum+">";
inputNum++;
str += "<input type=text name=text"+inputNum+"><br>";
ice.innerHTML = ice.innerHTML + str;
}
</script>
....
<tr>
<td>
<asp:Label id="Label3" runat="server" onclick="create()">Label</asp:Label>
</td>
</tr>
....
<asp:Button id="Button2" runat="server" Text="Button"></asp:Button>
|
|