我正在尝试解决Visual Studio中的错误,the suggestion is to stop using
UserControls
and use Control
instead..
所以我将我的所有UserControl转换为Control,例如:
public partial class Controls_UserManagement_GroupManager : System.Web.UI.UserControl { protected void Page_Load(object sender,EventArgs e) { if (!IsPostBack)
变
public partial class Controls_UserManagement_GroupManager : System.Web.UI.Control { protected void Page_Load(object sender,EventArgs e) { if (!IsPostBack)
除了没有Control.IsPostBack?
如何用Control替换UserControl?
系列
这个问题是正在进行的Stackoverflow系列中的一个,“模板化用户控件”:
> How to add a Templating to a UserControl?
> How to inherit from Control,rather than UserControl?
> UserControl has IsPostBack,but Control does not
> UserControl does not have public property named ContentTemplate
> How do i specify CodeFileBaseClass from web.config?
解决方法
Control有一个Page属性,它有一个IsPostback属性.这应该为您提供所需的价值.
public class MyControl : Control{ protected override void OnInit( EventArgs e ){ if( this.Page.IsPostBack ){ // do something } } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。