日期:2014-05-17 浏览次数:20459 次
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px"> </asp:Panel> <asp:HiddenField ID="HiddenField1" runat="server" /> <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" OnClientClick="saveValue();" /> <script> function saveValue() { var obj=document.getElementById("Panel1").getElementsByTagName("input"); for(var i=0;i<obj.length;i++) { if(obj.type="text") document.getElementById("HiddenField1").value+=obj[i].value+","; } alert(document.getElementById("HiddenField1").value) } </script>
------解决方案--------------------
我们只能跟随问答机器人后面接点分
SF都让他一个人占领了 速度太快
------解决方案--------------------
我也来凑个热闹,企图获得重金!!
生成一个TextBox,多个依次类推,放一个Hidden1,中间变量
页面html
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Button" OnClientClick="test()" />
<asp:Panel ID="Panel1" runat="server">
</asp:Panel>
<input id="Hidden1" type="hidden" runat="server" />
js:
<script type="text/javascript">
function test() {
document.getElementById("Hidden1").value = document.getElementById("myT1").value;
}
</script>
c#
protected void Button1_Click(object sender, EventArgs e)
{
this.sText();//动态生成TextBox
}
protected void Button2_Click(object sender, EventArgs e)
{
ViewState["t1"] = Hidden1.Value.ToString();//获得中间变量
this.sText();//动态生成TextBox
((TextBox)Panel1.FindControl("myT1")).Text = ViewState["t1"].ToString();//赋值
}
private void sText()
{
TextBox myT1 = new TextBox();
myT1.ID = "myT1";
Panel1.Controls.Add(myT1);
}
------解决方案--------------------