title: How to get the href from LiteralControl?
body: <p>I need to read the href from a <code>LiteralControl</code> and add some attributes to it:</p>
  
  <p>Markup;</p>
  
  <pre><code>&lt;a id="aMyAnchor" runat="server" href="bob.com"&gt;click me&lt;/a&gt;
  </code></pre>
  
  <p>Here's what I tried:</p>
  
  <pre><code>string url= "bob.com";
  var myAnchor = divLinkContainer.Controls
      .Cast&lt;LiteralControl&gt;()
      .Where(a =&gt; a.Attributes["href"]
      .Contains(url)).First();
  </code></pre>
  
  <p>However, <code>LiteralControl</code> does not have an attributes property...</p>
  
  <p><strong>NOTE: I know I can access the link directly via its id, but that's just because I made the example code simple.</strong></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This:</p>
  
  <pre><code>string url= "bob.com";
  var myAnchor = divLinkContainer.Controls
      .Cast&lt;HtmlAnchor&gt;()
      .Where(a =&gt; a.HRef
      .Contains(url)).First();
  </code></pre>
  
  <p>results in this:</p>
  
  <blockquote>
    <p>Unable to cast object of type 'System.Web.UI.LiteralControl' to type
    'System.Web.UI.HtmlControls.HtmlAnchor'.</p>
  </blockquote>