title: ASP.NET master page hyperlink controls not working
body: <p>I am new to ASP.NET (and web development in general).
  For some reason, in my ASP.NET master page, the hyperlink web controls are not working.</p>
  
  <p>I want them as web controls so I can change the "Login" hyperlink text to "Log out" (as well as its navigateURL) if the user session is currently logged in.</p>
  
  <p>Could anyone find the problem?</p>
  
  <p>Here is the code:</p>
  
  
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;link href="~/Styles/default.css" rel="stylesheet" type="text/css" /&gt;
      &lt;asp:ContentPlaceHolder ID="HeadContent" runat="server"&gt;
      &lt;/asp:ContentPlaceHolder&gt;
      &lt;style type="text/css"&gt;
          .style1
          {
              width: 468px;
          }
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="Form1" runat="server"&gt;
      &lt;div id="wrapper" runat="server"&gt;
          &lt;div id="header" class="container" runat="server"&gt;
              &lt;table style="width: 100%; height: 128px;" runat="server"&gt;
                  &lt;tr&gt;
                      &lt;td class="style1" runat="server"&gt;
                          WEBLINK
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;asp:HyperLink ID="HyperLink1" runat="server"&gt;About&lt;/asp:HyperLink&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;asp:HyperLink ID="HyperLink2" runat="server" 
                              NavigateUrl="~/InterestPages/InterestNews.aspx"&gt;Interests&lt;/asp:HyperLink&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;asp:HyperLink ID="HyperLink3" runat="server"&gt;Blogs&lt;/asp:HyperLink&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;asp:HyperLink ID="loginLink" runat="server" NavigateUrl="~/Account/Login.aspx" 
                              ViewStateMode="Enabled"&gt;Login&lt;/asp:HyperLink&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;asp:ContentPlaceHolder ID="MainContent" runat="server"&gt;
              &lt;/asp:ContentPlaceHolder&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Here is my C# master page code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  
  public partial class SiteMaster : System.Web.UI.MasterPage
  {
      private void Page_PreInit(object sender, EventArgs e)
      {
          if (Session["LoggedIn"] != null &amp;&amp; (bool)Session["LoggedIn"] == true)
          {
              MasterPageFile = "~/LoggedIn.master";
          }
          else
          {
              MasterPageFile = "~/Site.master";
          }
      } 
      protected void Page_Load(object sender, EventArgs e)
      {
          if (Session["LoggedIn"] != null &amp;&amp; (bool)Session["LoggedIn"] == true)
          {
              loginLink.Text = "Log out";
              loginLink.NavigateUrl = "";
          }
          else
          {
              loginLink.Enabled = true;
              loginLink.Text = "Login";
              loginLink.NavigateUrl = "~/Account/Login.aspx";
          }
      }
  
  
  }
  </code></pre>