I have a property in masterpage which i populate in page render event as below:
public string myproperty{get; set;}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
myproperty = "TEST";
}
on my aspx page I have a <%@ Reference VirtualPath="~/Site.Master" %> and on page init event I access it as so:
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Site msPage = (Site)Page.Master;
string t = msPage.myproperty ;
}
I can see the property on masterpage having a value but on aspx page it is always null. am I doing something wrong can someone help please.
I can recommend you to read this:
http://dotnetbyexample.blogspot.be/2007/10/right-way-of-accessing-master-page.html