作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在 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 中做些什么吗??
最佳答案
您应该始终在每次回发时重新加载 Page_init 上的用户控件。
关于c# - 动态加载用户控件 - 回发问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7849618/
我是一名优秀的程序员,十分优秀!