Reputation: 1147
I want to provibe a variable in my "Page_Load
" event on the Site.Master.Cs and put this value in my Site.Master.
I've do this but it doesn't work :
<asp:Literal ID="myControl" runat="server">
Hello
</asp:Literal>
And, in my Site.Master.Cs :
protected void Page_Load(object sender, EventArgs e)
{
Literal litStreamHtml = (Literal)this.Master.FindControl("myControl");
litStreamHtml.Text = "some text";
}
Upvotes: 0
Views: 280
Reputation: 343
Agreed with Luuk, also you could just use
myControl.Text = "some text";
Upvotes: 1
Reputation: 1969
You are already on the masterpage, so you don't have to reference the master (only in case you use nested master pages.
protected void Page_Load(object sender, EventArgs e)
{
Literal litStreamHtml = (Literal)this.FindControl("myControl");
litStreamHtml.Text = "some text";
}
Upvotes: 1