【发布时间】:2011-10-21 12:50:00
【问题描述】:
我试图在 aspx 页面上动态加载用户控件,但是它可以工作,但我遇到回发问题?我在用户控件上有一个图像按钮,我想显示图像但是当我单击按钮时页面刷新并且不显示图像?我在 aspx 页面和后端代码上有一个占位符,我有这个:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Control uc = Page.LoadControl("~/UserControls/Mycontrol.ascx");
placeholder1.Controls.Add(uc);
}
}
我需要在 page_preinit 或 page_init 中做些什么吗??
【问题讨论】:
标签: c# asp.net user-controls postback page-lifecycle