I am trying to create my ‘custom IsPostBack’, all I did was create a bool property,
bool test;
public bool MyPostBack
{
get{ test = Page.IsPostBack; return test; }
set{ test = value; }
}
when debugging, having set, eg, value to false, when test is true, after pressing F11, test remains as it is! I find this very strange. Do you have any idea why? Thank you.
The first thing you’re doing in the property getter is reseting it:
So, setting your MyPostBack property will have basically no effect because the value you set it to is overridden every time you get the property value.
You probably want something more like this:
The private variable (test) is initialized in the Page Load event to the value of the page’s IsPostBack property.