Adding runat = "server" does not display my server tags <% ...%> ...">

How to avoid adding runat = "server" that destroys my server tags <% ...%>

Adding runat = "server" does not display my server tags <% ...%>


I have a main page with several <li> for the menu, and since I have to set class = selected for the current page, I use a small server tag to find the URL and assign a specific class.

I have a total of 10 <li> and not all menus are available for all types of users, I need to switch several from <li> if the user is not an administrator, so I added runat = "server" so that I can set them visible = false via WITH#

Here's how it looks at first glance:

<li runat="server" id="liBlog" class='<%= Request.Url.AbsoluteUri.EndsWith("/Blog") ? "selected" : "" %>'><a href="/Blog">Group Blog</a></li>
<li runat="server" id="liPoll" class='<%= Request.Url.AbsoluteUri.EndsWith("/Poll") ? "selected" : "" %>'><a href="/Poll">Poll</a></li>
<li id="liInvite" class='<%= Request.Url.AbsoluteUri.EndsWith("/Invite") ? "selected" : "" %>'><a href="/Invite">Invite</a></li>
<li id="liFavourite" class='<%= Request.Url.AbsoluteUri.Contains("/Favourite") ? "selected" : "" %>'><a href="/Favourite">My Favourites</a></li>

<li> runat = "server" , class= "selected" class= "", , <li> , runat = "server".

, runat = "server", class= "" html, ! html , :

<li id="ctl00_ctl00_ContentPlaceHolder1_liBlog" class="&lt;%= Request.Url.AbsoluteUri.EndsWith(&quot;/Blog&quot;) ? &quot;selected&quot; : &quot;&quot; %&gt;"><a href="/Blog">Group Blog</a></li>

!

? ?

, google , , , .

+3
2

<%= %> , runat="server".

:

+4

ASP.NET XmlSiteMap, .

0

Source: https://habr.com/ru/post/1757327/


All Articles