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 9272067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:46:41+00:00 2026-06-18T15:46:41+00:00

In an ASP.NET MVC application, I have two radio buttons. Depending on a boolean

  • 0

In an ASP.NET MVC application, I have two radio buttons. Depending on a boolean value in the model, How do I enable or disable the radio buttons? (The values of the radio buttons are also part of the model)

My radio buttons currently look like this –

            @Html.RadioButtonFor(m => m.WantIt, "false")  
            @Html.RadioButtonFor(m => m.WantIt, "true")  

In the model, I have a property called model.Alive. If model.Alive is true I want to enable the radio buttons, else if model.Alive is false, I want to disable the radio buttons.
Thanks!

  • 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-06-18T15:46:42+00:00Added an answer on June 18, 2026 at 3:46 pm

    You could pass the values directly as htmlAttributes like so:

    @Html.RadioButtonFor(m => m.WantIt, "false", new {disabled = "disabled"})  
    @Html.RadioButtonFor(m => m.WantIt, "true", new {disabled = "disabled"})
    

    If you need to check for model.Alive then you could do something like this:

    @{
       var htmlAttributes = new Dictionary<string, object>();
       if (Model.Alive)
       {
          htmlAttributes.Add("disabled", "disabled");
       }
    }
    
    Test 1 @Html.RadioButton("Name", "value", false, htmlAttributes)
    Test 2 @Html.RadioButton("Name", "value2", false, htmlAttributes)
    

    Hope that helps

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

Sidebar

Related Questions

In the asp.net mvc 3 application I have two views which have the same
In an ASP.NET MVC application where I have the following model.. public class EventViewModel
I have two custom attributes in my asp.net mvc(C#) application. [CustAttribute1()] [CustAttribute2()] When I
I have two dropdownlist which shows places in my asp.net MVC(C#) application. The First
I have an ASP.NET MVC application and I am using two JQuery plugins: colorbox
I have an ASP.NET MVC application, and the visitors can select from two languages
I am writing an ASP.Net MVC application. I have two entities - patients and
I have an ASP.Net MVC application with a model which is several layers deep
In my ASP.NET MVC 3 application i have two types of users - regular
I am working on asp.net MVC 3 application and I have created a model.

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.