Is there a way I can find out if a Page has been posted back without using the Page object. I want to know if the page has been posted back without passing a parameter to the function, like you can check the Request object by using httpContext.Current.Request , is there a Page equivalent? The check occurs in a library function?
Here's another technique. You can get the Page from HttpContext, and check its IsPostBack method. That way you don't have to pass the page or an IsPostBack flag to your helper function.
void MyHelperFunction()
{
Page page = HttpContext.Current.Handler as Page;
bool isPostBack = (page != null) && (page.IsPostBack);
}
If you're only trying to avoid using the Page property, and not the Page class, you can cast HttpContext.Current.Handler to a Page object in the context of a standard page request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With