gpt4 book ai didi

c# - 动态加载用户控件 - 回发问题

转载 作者:行者123 更新时间:2023-11-30 19:46:49 25 4
gpt4 key购买 nike

我试图在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com