if(!Page.IsPostBack)
{
for(int i = 0; i < 3; i ++)
{
TextBox txt = new TextBox();
txt.ID = "txt" + i;
this.Panel1.Controls.Add(txt);
}
}
改为
for(int i = 0; i < 3; i ++)
{
TextBox txt = new TextBox();
txt.ID = "txt" + i;
this.Panel1.Controls.Add(txt);
}
{
for(int i = 0; i < 3; i ++)
{
TextBox txt = new TextBox();
txt.ID = "txt" + i;
this.Panel1.Controls.Add(txt);
}
}
改为
for(int i = 0; i < 3; i ++)
{
TextBox txt = new TextBox();
txt.ID = "txt" + i;
this.Panel1.Controls.Add(txt);
}
解决方案 »
- ie与IIS之间连接问题
- 急急急急急急!!!!!!!!!!!!!
- sqlhelper 为什么用静态类。
- JavaScript event=onclick 的問題.
- 请问如何接受Post方法传过来的数据
- Dottext 学习中的一些问题,Dottext.Framework.ScheduledEvents 等等
- repeater分页的问题.
- 在2005。net中,我在gridview中放入dropdownlist,可是却找不到dropdownlist,为什么?
- [100分],求:按住鼠标左键滑过表格,表格的单元格或行响应什么事件?在线,对了立即给分.
- Asp.net MS Chart滚动条
- 用水晶报表导出.pdf文件,用win98+Reader5.0再显示在网页上,有时有“文件不以‘%pdf-’开始“的错误的提示
- 请问,在ASP.NET中如何调用Windows API?
if(!Page.IsPostBack)内
这里的代码只在页面第一次加载的时候才执行的
提交后Page.IsPostBack就是true就不执行你写的代码了
让页面每次执行时都生成你为什么自动生成或者你把TextBox开始隐藏点按钮时显示出来
{
for(int i = 0; i < 3; i ++)
{
TextBox txt = new TextBox();
txt.ID = "txt" + i;
this.Panel1.Controls.Add(txt);
}
}private void Button1_Click(object sender, System.EventArgs e)
{
string str = "";
for(int i = 0; i < 3; i ++)
{
TextBox txt = (TextBox)Panel1.FindControl("txt" + i);
str += "第" + i.ToString() + "个文本框的值为:" + txt.Text + "<br>";
}
this.Label1.Text = str;
}
让页面每次执行时都生成你为什么自动生成或者你把TextBox开始隐藏点按钮时显示出来
TextBox txt1=new TextBox();
TextBox txt2=new TextBox();private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!this.IsPostBack)
{
this.EnsureChildControls();
txt1.Text="hello";
this.EnsureChildControls();
txt2.Text="world";
}
}protected override void CreateChildControls()
{
pnl1.Controls.Add(txt1);
pnl1.Controls.Add(txt2);
}
</script>
{
for(int i = 0; i < 3; i ++)
{
TextBox txt = new TextBox();
txt.ID = "txt" + i;
this.Panel1.Controls.Add(txt);
}
}
改为:
for(int i = 0; i < 3; i ++)
{
TextBox txt = new TextBox();
txt.ID = "txt" + i;
this.Panel1.Controls.Add(txt);
}