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
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 to share