I am trying to use codebehind variable in if statement. This is my statement.
<title><%If ("<%= title_tag%>".ToString().Contains("MI") = True) Then%>
MI
<% Else %>
MC
<%End If %>
</title>
But If I remove the codebehind variable and just use
<title><%If ("Home Care MI".ToString().Contains("MI") = True) Then%>
MI
<% Else %>
MC
<%End If %>
</title>
It works well. I've also tried escaping codebehind variable in two curly braces but it didn't help.
I finally came through. Thanks for your support. I think the issue was in contains and tostring function.
<title><%IF title_tag = "Earlier Title" Then%>
MI
<% Else %>
MC
<%End If %>
</title>
Make sure you declare the variable as public in your code behind file and no need to use <% or " around variales...
<title><%If (title_tag.ToString().Contains("MI") = True) Then%>
MI
<% Else %>
MC
<%End If %>
</title>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With