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

  • Home
  • SEARCH
  • 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 7942211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:54:03+00:00 2026-06-03T23:54:03+00:00

I am developing an ASP.Net MVC 3 Web Application using Razor Views. Within the

  • 0

I am developing an ASP.Net MVC 3 Web Application using Razor Views. Within the View I would like to ask the user a question which can only have a Yes/ No answer, therefore, I am planning on using two Radio Buttons.

I have a ViewModel which I pass to my View, and it looks like this

public class ViewModelFormImmigration
{
    public int immigrationID { get; set; }
    public int formID { get; set; }

    [Required(ErrorMessage = "Please select Yes or No.")]
    public bool euNational { get; set; }
}

In my View I then have the following lines of code to display the radio buttons for both the Yes and No options

@Html.RadioButtonFor(model => model.euNational, true) <text>Yes</text>
@Html.RadioButtonFor(model => model.euNational, false) <text>No</text>

My problem is that, when the User comes to this View for the first time, I would like neither the Yes or No option selected. At the moment, when I create an instance of my ViewModel (see above), the property euNational is defaulted to false and when the ViewModel is passed to my View, this means that the option No is automatically selected.

Is there anyway around this so that when the User see’s the View for the first time, that no option is not selected by default?

Thanks for your help everyone.

  • 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-03T23:54:05+00:00Added an answer on June 3, 2026 at 11:54 pm

    Try changing:

    [Required(ErrorMessage = "Please select Yes or No.")]
    public bool euNational { get; set; }
    

    To:

    [Required(ErrorMessage = "Please select Yes or No.")]
    public bool? euNational { get; set; }
    

    This way, when you first load the view with no value set for euNational it will not set to neither true or false. As at the moment when it has no value set, it defaults to false

    • 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 MVC 3 web application using Razor and C#. I
I am developing an ASP.Net MVC 3 Web application using Entity Framework 4.1 and
I am developing an ASP.Net MVC 3 Web application using Entity Framework 4.1, however,
I'm developing a web application using ASP .NET MVC 1.0 and jQuery (including the
I'm developing a web application using asp.net Mvc 2 and NHibernate, and I'm paging
I'm developing an web application using asp.net mvc, and i need to do a
I am developing a web application using asp.net mvc... I am listing out the
I am developing a web application using Asp.net mvc framework with concept of sub
We are currently developing a web application in ASP.NET MVC which would really benefit
I am developing an ASP.Net MVC 3 Web application using Entity Framework 4.1. 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.