title: How to disable an HyperLink in ASP.NET MVC3 with Html Helpers without spoiling the View?
body: <p>I am developing an ASP.NET MVC3 application with Razor and C#. I wanted to know if there is any way to "disable" an <strong>hyperlink</strong> rendered with the <code>Html.ActionLink</code> helper without spoiling my View with <strong>if</strong> constructs. As for disable I mean the link becomes not clickable, greyed out and without the underline.</p>
  
  <p>To make things clear I hereby attach the <em>as-is</em> code I currently use to make the trick. Instead of disabling the <strong>hyperlink</strong> I just display N/A as plain text. </p>
  
  <p>The part of the View:</p>
  
  <pre><code> &lt;td&gt;@if(topic.EnableTopicDownloadLink)
      {
          @Html.ActionLink("Presentation", "Download", new { topicId = topic.TopicId })
      }
      else
      {
           @Html.Raw("N/A");
      }           
  &lt;/td&gt;
  
  &lt;td&gt;@if (topic.EnableTopicWatchLink)
      {
          @Html.ActionLink("Video", "Play", new { topicId = topic.TopicId })
      }
      else
      {
          @Html.Raw("N/A");
      }     
  &lt;/td&gt;
  </code></pre>
  
  <p>And the ViewModel passed to the View</p>
  
  <pre><code>public class TopicDownloadViewModel
      {
          public int TopicId { get; set; }
          public string TopicName { get; set; }
          public string TopicPresenter { get; set; }
          public string TopicStartTime { get; set; }
          public string TopicEndTime { get; set; }
          public bool EnableTopicWatchLink { get; set; }
          public bool EnableTopicDownloadLink { get; set; }
  
          public TopicDownloadViewModel(WebinarTopic webinarTopic)
          {
              TopicId = webinarTopic.TopicId;
              TopicName = webinarTopic.TopicName;
              TopicPresenter = webinarTopic.TopicPresenter;
              TopicStartTime = String.Format("{0:t}", webinarTopic.TopicStartTime);
              TopicEndTime = String.Format("{0:t}", webinarTopic.TopicEndTime);
              EnableTopicWatchLink = (webinarTopic.TopicVideoWatchLink != null) ? true : false;
              EnableTopicDownloadLink = (webinarTopic.TopicSlidesDownloadLink != null) ? true : false;
          }
      }
  </code></pre>
  
  <p>I know there is a <em>disabled HTML attribute</em> for <code>&lt;a&gt;</code> but the only way to enable the link is to omit the attribute and I have no clue how to do it without using jQuery. My intension is not to use jquery if feasible.</p>
  
  <p>Thanks</p>
  
  <p>Francesco</p>