i'm trying check if control(means user custom controls *ascx
) placed on correct page and i getting error - how to solve it
Control Page_Load
:
protected void Page_Load(object sender, EventArgs e)
{
ddl.enable = (Page as Online.MyPage);
}
Error:
Object reference not set to an instance of an object.
But if we look on page life cycle it's possible:
Page: PreInit
Control: Init
Page: Init
Page: InitComplete
Page: PreLoad
Page: Load
Control: Load
ThanX
UDP:
I think it can be some like this but i think it's a wrong way.
var v = Page as Online.MyPage;
if (v != null)
ddl.enable = v;
UPD:
ddl.enable - means dropdownlist
DropDownList ddList = new DropDownList();
ddList.Enabled = y;
I dont want to delegate parent page right to operate control by property, just want to solve this across control.