R – Stack overflow when setting MasterPage properties

asp.netmaster-pagesnetuser-controls

I'm getting a stack overflow when tryin to set a public property in a MasterPage from an ASPX page.

I'm making a "greeting card" editor, using a TabContainer. Each tab has a user control, and everything is updated when active tab is changed – while doing so I need to store all the data away in master page properties.

From the ASPX page:

protected void tcTabs_ActiveTabChanged(object sender, EventArgs e)
{
    Master.Message = "blahblah";
}

From the MasterPage:

public string Message
{
    get { return Message; }
    set { Message = value; }
}

And this is where I get a stack overflow; in the set {}. Doesn't really matter what I try to set, I get the same problem every time. I'm sure I'm missing some minor thing, but as far as I can see I'm following all the examples I've found.

Best Answer

The problem is that the Message property is calling itself. You need to set a member variable or control property.

Edit: example:

string mMessage = string.Empty;

public string Message
{
    get { return mMessage; }
    set { mMessage = value; }
}
Related Topic