Hello,
I just started working with nested master pages....
I have a grandparent master page that has an <asp:Label id="lblUserName" runat=server>. In the code behind I can reference it just fine, but when I put a nested master page in between my grandparent master page and my content page, when the parent master page loads and tries to access his own control "lblUserName" I get an "Object reference not set to an instance of an object" error. If I have the content page reference the grandparent master page directly (no nested master) it works great, but as soon as I try to have my content page belong to a nested master page (which has the grandparent master as his master), the web control lblUserName is null.
This is the code in the GrandParentMaster code behind page.
any advice would be appreciated.
Thanks much!
I just started working with nested master pages....
I have a grandparent master page that has an <asp:Label id="lblUserName" runat=server>. In the code behind I can reference it just fine, but when I put a nested master page in between my grandparent master page and my content page, when the parent master page loads and tries to access his own control "lblUserName" I get an "Object reference not set to an instance of an object" error. If I have the content page reference the grandparent master page directly (no nested master) it works great, but as soon as I try to have my content page belong to a nested master page (which has the grandparent master as his master), the web control lblUserName is null.
This is the code in the GrandParentMaster code behind page.
Code:
private String _userName;
private User _thisUser;
public String UserName
{
get
{
_userName = this.lblUserName.Text; //errs on this line
return _userName;
}
set
{
_userName = value;
this.lblUserName.Text = _userName; //or errs on this line
}
}
any advice would be appreciated.
Thanks much!