UserControl has IsPostBack, but Control does not

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)

becomes

public partial class Controls_UserManagement_GroupManager : System.Web.UI.Control
{
    protected void Page_Load(object sender, EventArgs e)
    {
       if (!IsPostBack)

Except that there is no Control.IsPostBack?

How do i replace UserControl with Control?

Series

This question is one in the ongoing Stackoverflow series, "Templating user controls":

Answers


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
        }
    }
}

MSDN Reference


Need Your Help

how could I intercept linux sys calls?

c linux redirect hook

Besides the LD_PRELOAD trick , and Linux Kernel Modules that replace a certain syscall with one provided by you , is there any possibility to intercept a syscall ( open for example ) , so that it f...

Why is Perl squashing my array?

perl

Here's a short test program:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.