Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accessing web controls from a master master page

Status
Not open for further replies.

jrenae

Programmer
Jan 18, 2006
142
US
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.

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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top