c# - How to display item in .aspx page using if -


here want display list menu element based on if condition. here want to check if session["user_id"] empty or not. if empty display

        <li><a href="register.aspx">register</a></li>                    <li><a href="login.aspx">login</a></li>  

else display

<li><a href="login.aspx">login</a></li>  

index.aspx

<div class="navbar">         <ul>             <li><a href="index.aspx">home</a></li>             <li><a href="about.aspx">about us</a></li>             <li><a href="feedback.aspx">feedback</a></li>             <li><a href="rti.aspx">rti</a></li>             <li><a href="faq.aspx">faq</a></li>             <li><a href="contactus.aspx">contact us</a></li>             <li><a href="register.aspx">register</a></li>                        <li><a href="login.aspx">login</a></li>                  </ul>     </div> 

c#

string userid = convert.tostring(session["user_id"]);                 if (string.isnullorempty(userid) == true)         {                         response.redirect("login.aspx");         } 

how can this?

in asp.net, can mix html , c# :

    <% string userid = convert.tostring(session["user_id"]);             if (string.isnullorempty(userid) == true)     {  %>                     <li><a href="register.aspx">register</a></li>                      <li><a href="login.aspx">login</a></li>      <%}else{ %>         <li><a href="login.aspx">login</a></li>     <%} %>   

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -