动态加载用户控件的问题,高手帮忙看看,每次交替加载之后,控件上的按钮要点两次才能响应事件 10
if(!Page.IsPostBack){Session["cname"]="WebUserControl1.ascx";}addcontrol();}protected...
if (!Page.IsPostBack)
{
Session["cname"] = "WebUserControl1.ascx";
}
addcontrol();
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["cname"] = "WebUserControl1.ascx";
addcontrol();
}
protected void Button2_Click(object sender, EventArgs e)
{
Session["cname"] = "WebUserControl2.ascx";
addcontrol();
}
void addcontrol() {
Control uc = LoadControl(Session["cname"].ToString());
Panel1.Controls.Clear();
Panel1.Controls.Add(uc);
} 展开
{
Session["cname"] = "WebUserControl1.ascx";
}
addcontrol();
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["cname"] = "WebUserControl1.ascx";
addcontrol();
}
protected void Button2_Click(object sender, EventArgs e)
{
Session["cname"] = "WebUserControl2.ascx";
addcontrol();
}
void addcontrol() {
Control uc = LoadControl(Session["cname"].ToString());
Panel1.Controls.Clear();
Panel1.Controls.Add(uc);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询