开发者

variable declared in master page not available in content page

开发者 https://www.devze.com 2023-02-10 07:26 出处:网络
I have the master page code behind like this: public partial class TheMasterPage : System.Web.UI.MasterPage

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消