This is driving me crazy, because I thought I had the runat=server
stuff totally figured out.
I have an asp:Literal
control in my markup (it's in a masterpage, but that doesn't matter, right?)
In MyMaster.Master
:
<asp:Literal ID="myLiteral" runat="server" Text="Some Text"></asp:Literal>
Then, in the codebehind (MyMaster.Master.cs
), I have:
myLiteral.Text = "Some different text";
No matter what I try, I get
The name 'myLiteral' does not exist in the current context
I've tried cleaning and rebuilding my whole solution, but it doesn't make any difference.
What am I doing wrong?
Edit: To clarify, I'm trying to change the text of the Literal control in the codebehind of the master page, not a content page. Specifically, I'm doing this in the Page_Load
method of the master file.