用户控件具有的IsPostBack,但控制不 [英] UserControl has IsPostBack, but Control does not
本文介绍了用户控件具有的IsPostBack,但控制不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图解决在Visual Studio中的一个bug,的建议是用户控件
停止使用,并使用控制
来代替。。
i'm trying to solve a bug in Visual Studio, the suggestion is to stop using UserControls
and use Control
instead..
所以我将所有我的用户控件
逼到控制
,例如:
So i'm converting all my UserControl
into just Control
, e.g.:
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
?
我如何更换用户控件
与控制
?
这个问题是一个在正在进行的系列#1,模板的用户控件
This question is one in the ongoing Stackoverflow series, "Templating user controls":
- How一个模板添加到用户控件?
- How从控制继承,而不是用户控件?
- UserControl拥有的IsPostBack,但控制不
- UserControl不具有公共属性命名的ContentTemplate
- How我该从web.config中指定codeFileBaseClass?
- 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?
推荐答案
控制
有一个页
属性,该属性有一个的IsPostBack
属性。这应该给你你需要的值。
Control
has a Page
property, which has an IsPostback
property. This should give you the value you need.
public class MyControl : Control{
protected override void OnInit( EventArgs e ){
if( this.Page.IsPostBack ){
// do something
}
}
}
这篇关于用户控件具有的IsPostBack,但控制不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文