variable declared in master page not available in content page
I have the master page code behind like this:
public partial class TheMasterPage : System.Web.UI.MasterPage
{
string test = null;
protected void Page_Init(object sender, EventArgs e)开发者_如何学编程
{}
}
When I'm in the Page_Load function in the code behind of the content page, I don't see the variable test as being available. Am I declaring it wrong?
Thanks.
Your property should be public and should have get, set
public string test
{
get; set;
}
I already answered it a little early Accessing property of master page inside content page
Having a master Page is not the same as inheriting a page class. What you would want to do is have a public property on the master page, and then access that from the content page.
精彩评论