You need to set it as a property in order to use it in the markup.
In code:
Private _useCss As Boolean
Public Property UseCss() As Boolean
Get
Return _useCss
End Get
Set(ByVal value As Boolean)
_useCss = value
End Set
End Property
Then in the markup:
<% If UseCss = True Then %>
Your stylesheet link tag here
<% Else %>
else could be optional if you won't load anything
<% End If %>
Alternatively, you can:
<% If UseCss = True Then
Response.Write("text")
Else
Response.Write("something else")
End If
%>
- head CSS. .
:
<head runat="server" id="head">
<%-- whatever you typically place here --%>
</head>
, , :
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If useCss Then
Dim stylesheet As New HtmlGenericControl("link")
stylesheet.Attributes.Add("rel", "stylesheet")
stylesheet.Attributes.Add("type", "text/css")
stylesheet.Attributes.Add("href", "../css/myCssFile.css")
FindControl("head").Controls.Add(stylesheet)
End If
End Sub