title: How to set html link <a href> dynamically using C#
body: <p>I have a menu in my web application like this</p>
  
  <pre><code>&lt;div&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href="http://localhost:52451/Voronezh/Settings.aspx"&gt;Settings&lt;/a&lt;/li&gt;
      &lt;li&gt;&lt;a href="http://localhost:52451/LoginPages/Welcome.aspx"&gt;Log out&lt;/a&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I would like to set these href links dynamically if some special condition is true.</p>
  
  <p>I've tried the following:</p>
  
  <p>HTML code</p>
  
  <pre><code>&lt;li&gt;&lt;a runat="server" id="toSettings" onserverclick="toSettings_ServerClick"&gt;Settings&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <p>C# code</p>
  
  <pre><code>protected void toSettings_ServerClick(object sender, EventArgs e)
      {
         if (condition)
           toSettings.HRef = "http://localhost:52451/Voronezh/Settings.aspx"; 
         else
           {...}      
      }
  </code></pre>
  
  <p>but it doesn't work: I stay on the same page instead of moving to the Settings page.</p>
  
  <p>Where is a mistake? What should be changed?</p>
  
  <p>Thanks in advance.</p>