title: How to avoid Adding runat="server" destroying my server tags <%...%>
body: <h3>Adding runat="server" is not rendering my server tags &lt;%...%&gt;</h3>
  
  <p><br>
  I have a masterpage with a few  &lt;li&gt; for menu and since I have to set class=selected for the current page, I am using a little server tag to find the url and assign the particular class.</p>
  
  <p>I have total of 10 &lt;li&gt; and not all menu is available to all types of user, I need to toggle few of the &lt;li&gt; if the user is not admin, so I have runat="server" added to them so I can set their visible=false through c#</p>
  
  <p>Here is how it is at a glance:</p>
  
  <pre><code>&lt;li runat="server" id="liBlog" class='&lt;%= Request.Url.AbsoluteUri.EndsWith("/Blog") ? "selected" : "" %&gt;'&gt;&lt;a href="/Blog"&gt;Group Blog&lt;/a&gt;&lt;/li&gt;
  &lt;li runat="server" id="liPoll" class='&lt;%= Request.Url.AbsoluteUri.EndsWith("/Poll") ? "selected" : "" %&gt;'&gt;&lt;a href="/Poll"&gt;Poll&lt;/a&gt;&lt;/li&gt;
  &lt;li id="liInvite" class='&lt;%= Request.Url.AbsoluteUri.EndsWith("/Invite") ? "selected" : "" %&gt;'&gt;&lt;a href="/Invite"&gt;Invite&lt;/a&gt;&lt;/li&gt;
  &lt;li id="liFavourite" class='&lt;%= Request.Url.AbsoluteUri.Contains("/Favourite") ? "selected" : "" %&gt;'&gt;&lt;a href="/Favourite"&gt;My Favourites&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <p>The &lt;li&gt; without runat="server" works fine, when on correct page the source code shows class="selected" or class="" as appropriate, the other &lt;li&gt; used to work fine too, until I decided to add the runat="server".</p>
  
  <p>Once I added that runat="server", the whole block of class="" is being sent out to the html page, its not processing the server tags at all! I right click on the html and look at the source, it's being rendered as: </p>
  
  <pre><code>&lt;li id="ctl00_ctl00_ContentPlaceHolder1_liBlog" class="&amp;lt;%= Request.Url.AbsoluteUri.EndsWith(&amp;quot;/Blog&amp;quot;) ? &amp;quot;selected&amp;quot; : &amp;quot;&amp;quot; %&amp;gt;"&gt;&lt;a href="/Blog"&gt;Group Blog&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <p>It's pouring out my server tags into the source code!</p>
  
  <p>Why is this behaviour seen? How can I avoid it? </p>
  
  <p>I looked up a lot of similar threads in here and there was nearly nothing in google, so made this, I dont think this is a duplicate question.</p>