title: Is inline code in your aspx pages a good practice?
body: <p>If I use the following code I lose the ability to right click on variables in the code behind and refactor (rename in this case) them</p>
  
  <pre><code>&lt;a href='&lt;%# "/Admin/Content/EditResource.aspx?ResourceId=" + Eval("Id").ToString() %&gt;'&gt;Edit&lt;/a&gt;
  </code></pre>
  
  <p>I see this practice everywhere but it seems weird to me as I no longer am able to get compile time errors if I change the property name.
  My preferred approach is to do something like this</p>
  
  <pre><code>&lt;a runat="server" id="MyLink"&gt;Edit&lt;/a&gt;
  </code></pre>
  
  <p>and then in the code behind</p>
  
  <pre><code>MyLink.Href= "/Admin/Content/EditResource.aspx?ResourceId=" + myObject.Id;
  </code></pre>
  
  <p>I'm really interested to hear if people think the above approach is better since that's what I always see on popular coding sites and blogs (e.g. Scott Guthrie) and it's smaller code, but I tend to use ASP.NET because it is compiled and prefer to know if something is broken at compile time, not run time.</p>