Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6033503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:29:32+00:00 2026-05-23T05:29:32+00:00

I am developing an ASP.NET MVC3 application with Razor and C#. I wanted to

  • 0

I am developing an ASP.NET MVC3 application with Razor and C#. I wanted to know if there is any way to “disable” an hyperlink rendered with the Html.ActionLink helper without spoiling my View with if constructs. As for disable I mean the link becomes not clickable, greyed out and without the underline.

To make things clear I hereby attach the as-is code I currently use to make the trick. Instead of disabling the hyperlink I just display N/A as plain text.

The part of the View:

 <td>@if(topic.EnableTopicDownloadLink)
    {
        @Html.ActionLink("Presentation", "Download", new { topicId = topic.TopicId })
    }
    else
    {
         @Html.Raw("N/A");
    }           
</td>

<td>@if (topic.EnableTopicWatchLink)
    {
        @Html.ActionLink("Video", "Play", new { topicId = topic.TopicId })
    }
    else
    {
        @Html.Raw("N/A");
    }     
</td>

And the ViewModel passed to the View

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;
        }
    }

I know there is a disabled HTML attribute for <a> 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.

Thanks

Francesco

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:29:33+00:00Added an answer on May 23, 2026 at 5:29 am

    I i understood correctly, main problem is that you don’t wish to create additional If -s. I would do custom helper in your place

    public static MvcHtmlString ActionLink<TModel>(this HtmlHelper<TModel> helper, string linkText, string action, object routeValues, bool disable)
        {
            if (disable)
            {
                return helper.ActionLink(linkText, action, routeValues, new { disabled = "disabled" });
            }
            return helper.ActionLink(linkText, action, routeValues);
        }
    

    and pass the last value, as you use to, but in parameter, without @if

        @Html.ActionLink("Presentation", "Download", topic.EnableTopicDownloadLink)
    

    My code needs modifications to accept custom htmlattributes (topicId) and merge with disabled. For this, you could use HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); and merge disabled attribute with returned value in method body

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an ASP.NET MVC3 application in C# and Razor. The architecture of
I am developing a web application in ASP.NET MVC3 with C# and Razor. I
I am developing a web application in ASP.NET MVC3 with C# and Razor. I
I am developing a web application in ASP.NET MVC3 with C# and Razor. The
I am developing an ASP.NET MVC3 application with c# and Razor. I created a
I'm developing an ASP.NET MVC3 application using the new Razor view engine but I'm
I am developing an ASP.NET MVC3 application with C# and Razor. I set up
I am developing an application in ASP.NET MVC3 in C#. I am currently building
I have been developing an application in asp.net mvc3. We have used models to
I am developing an ASP.NET MVC 3 web application using Razor and C#. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.