这里是我在做什么禁用回发按钮ASP.NET C#
为例Page Load
{
//Adds items to a panel (not an updatepanel just a normal panel control)
}
protected void btnNexMod_Click(object sender, EventArgs e)
{
// Calls DoWork() and Appends more items to the same panel
}
我的问题是,ASP:按钮是做回传以及调用DoWork()
因此,再打电话给我的页面加载,重新初始化我的面板:(
我想我的项目,我添加到面板呆在那里!
所有帮助表示赞赏,不寻找你的答案类型的交易。任何步骤表示赞赏谢谢!
下面是我的问题的确切例子。
protected void Page_Load(object sender, EventArgs e)
{
CheckBox chkbox = new CheckBox();
chkbox.Text = "hey";
chkbox.ID = "chk" + "hey";
// Add our checkbox to the panel
Panel1.Controls.Add(chkbox);
}
protected void Button1_Click(object sender, EventArgs e)
{
CheckBox chkbox = new CheckBox();
chkbox.Text = "hey";
chkbox.ID = "chk" + "hey";
// Add our checkbox to the panel
Panel1.Controls.Add(chkbox);
}
只有页面上的东西是一个空面板和一个按钮,这个点击偶处理程序。
我也试过这个,它仍然不起作用。现在它清除附加到面板上的初始项目。
if (!Page.IsPostBack) // to avoid reloading your control on postback
{
CheckBox chkbox = new CheckBox();
chkbox.Text = "Initial";
chkbox.ID = "chk" + "Initial";
// Add our checkbox to the panel
Panel1.Controls.Add(chkbox);
}
Page.IsPBackBack是你的朋友。 – jrummell
什么我可以在这里与面板上的视图状态? – clamchoda