读取在placeholder中动态生成TextBox内数据的问题? 因为点击第二个按钮时,页面PostBack了,而此时你动态添加的控件没有重新装载。需要在PostBack时重新添加这些文本框。我帮你改改,稍候。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 update.aspx <form id="Form1" method="post" runat="server"><asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder><asp:label id="Label1" runat="server">Label</asp:label><asp:Button id="Button1" onclick="AddControls" runat="server" Text="Button"></asp:Button><asp:Button id="Button2" onclick="UpdateClick" runat="server" Text="Button"></asp:Button></form>update.aspx.cspublic void Page_Load(Object Sender, EventArgs e) { //....... //reload the controls if (ViewState["ControlLoaded"] != null) { for (int i=0; i<=3; i++) { TextBox myTextBox= new TextBox(); myTextBox.ID ="myBox"+i; myTextBox.Text="aaaa"+i; PlaceHolder1.Controls.Add(myTextBox); } } }public void AddControls(Object Sender, EventArgs e) { for (int i=0; i<=3; i++) { TextBox myTextBox= new TextBox(); myTextBox.ID ="myBox"+i; myTextBox.Text="aaaa"+i; PlaceHolder1.Controls.Add(myTextBox); } // Set the View State ViewState["ControlLoaded"] = "true";} public void UpdateClick(Object Sender, EventArgs e) { TextBox Box;for (int i=0; i<=3; i++) { Box=(TextBox)PlaceHolder1.FindControl("myBox"+i); Label1.Text +=Box.text; } } MVC项目中使用ef实体 model的具体分层? datalist嵌套datalist问题 在弹出的DIV层上显示走动的倒计时 100分求显示数据问题!来拿分解决马上给!在线等!顶者给分! 我的VS.NET总提示这样的问题,哪个能帮我看一下 gridview 标题问题 请有经验的同仁为我最近作的项目定个价 asp.net如何实现二级分类`? 想尽快掌握.net开发,朋友们给点意见!!! 大家来谈一谈微软Passport的运作机制? 动态生成TextBox控件,如何使用循环取得每个控件里边的值? 如何能在新打开的页面窗口关闭后,取得其中的某个值
<form id="Form1" method="post" runat="server">
<asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>
<asp:label id="Label1" runat="server">Label</asp:label>
<asp:Button id="Button1" onclick="AddControls" runat="server" Text="Button"></asp:Button>
<asp:Button id="Button2" onclick="UpdateClick" runat="server" Text="Button"></asp:Button>
</form>
update.aspx.cs
public void Page_Load(Object Sender, EventArgs e)
{
//.......
//reload the controls
if (ViewState["ControlLoaded"] != null)
{
for (int i=0; i<=3; i++)
{
TextBox myTextBox= new TextBox();
myTextBox.ID ="myBox"+i;
myTextBox.Text="aaaa"+i;
PlaceHolder1.Controls.Add(myTextBox);
}
}
}public void AddControls(Object Sender, EventArgs e)
{
for (int i=0; i<=3; i++)
{
TextBox myTextBox= new TextBox();
myTextBox.ID ="myBox"+i;
myTextBox.Text="aaaa"+i;
PlaceHolder1.Controls.Add(myTextBox);
} // Set the View State
ViewState["ControlLoaded"] = "true";
}
public void UpdateClick(Object Sender, EventArgs e)
{
TextBox Box;
for (int i=0; i<=3; i++)
{
Box=(TextBox)PlaceHolder1.FindControl("myBox"+i);
Label1.Text +=Box.text;
}
}