ASP.NET IsPostBack without page

Is there a way to find out if a page has been loaded without using the Page object. I want to know if the page was posted back without passing a parameter to the function, for example you can check the Request object with httpContext.Current.Request, is there a page equivalent? Is the check done in a library function?

+3


source to share


3 answers


If you are trying to avoid using a page property rather than a Page class, you can use HttpContext.Current.Handler on the page object in the context of a standard page request.



+2


source


Here's another method. You can get the page from HttpContext and check its IsPostBack method. This way, you don't need to pass the page or IsPostBack flag to your helper function.



void MyHelperFunction()
{   
    Page page = HttpContext.Current.Handler as Page;
    bool isPostBack = (page != null) && (page.IsPostBack);
}

      

+2


source


Yes

  • Make sure the HTTP POST verb
  • Check the form collection for the value associated with "__PREVIOUSPAGE"

See also here

+1


source







All Articles