I have a master and content page:
1) On master page:
Markup:
<h1 id="SeoActionH1" runat="server"></h1>
Code behind:
public string SeoActionHeader1
{
set
{
SeoActionH1.InnerText = string.IsNullOrEmpty(value) ? string.Empty : value;
}
get
{
return SeoActionH1.InnerText;
}
}
2) On content page:
Code behind:
private Main MainMasterPage
{
get { return Master as Main; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string groupName = MainMasterPage.SeoActionHeader1;
}
}
If for example the content of h1 is: Hello, I've got the following:
"\r\n "
What's going on?
did you call this SeoActionHeader1
property on page load event?
or ty this way
public string MyString{ get; set; }
public void Page_Load(object sender, EventArgs e)
{
MyString = string.IsNullOrEmpty(value) ? string.Empty : value;
}
Then in your markup:
<h1><%= MyString %></h1>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.