Reputation: 5699
I'm new to C# web development. Please bear with me.
I'm trying to reference a param from Site.Master.cs in Site.Master, so that in Site.Master page, I can do:
<%
if (someParam == true) {
%>
some HTML code
<%
}
%>
The param someParam is the one I want to pass from Site.Master.cs.
Thanks!
Upvotes: 0
Views: 1064
Reputation: 1450
Follow the below code example.
Site.Master.cs
protected bool someParam
{
get;
set;
}
Site.Master page
<%
if (someParam) {
%>
some HTML code
<%
}
%>
Upvotes: 0
Reputation: 190976
You can use a LiteralControl
.
<asp:Literal ID="myControl" runat="server">
// Some html here.
</asp:Literal>
Then in the codebehind - set the Visible
property appropriately.
Upvotes: 1
Reputation: 39329
Use a class-level field (or better: property) with visibility at least "protected" (not private).
Upvotes: 2