Hi,
I set a value of a property in the Page_Load event and then on a postback the value is not correct in the OnInit event. Can someone please tell me how to fix this?
private int _myprop = -1;
public int myproperty {
get{ return _myprop; }
set{ _myprop = value; }
override protected void OnInit(EventArgs e)
{
if( myproperty != -1 )
DoThis();
}
private void Page_Load( Object source, System.EventArgs e )
{
if( !IsPostBack )
myproperty = 1;
}
Ok so when I load up the page the value of myproperty changes to 1. Then on a postback OnInit should DoThis(). But it's not working. The value of myproperty is consistantly -1. Why is this and how can I fix it?
Thanks,
ghesse
I set a value of a property in the Page_Load event and then on a postback the value is not correct in the OnInit event. Can someone please tell me how to fix this?
private int _myprop = -1;
public int myproperty {
get{ return _myprop; }
set{ _myprop = value; }
override protected void OnInit(EventArgs e)
{
if( myproperty != -1 )
DoThis();
}
private void Page_Load( Object source, System.EventArgs e )
{
if( !IsPostBack )
myproperty = 1;
}
Ok so when I load up the page the value of myproperty changes to 1. Then on a postback OnInit should DoThis(). But it's not working. The value of myproperty is consistantly -1. Why is this and how can I fix it?
Thanks,
ghesse