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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:19:46+00:00 2026-05-31T00:19:46+00:00

Within an admin page I originally was generating several checkboxes within a view as

  • 0

Within an admin page I originally was generating several checkboxes within a view as per below:

Model:

public class Foo
{
    public const string Bar = "SomeString";
}

View:

@Html.CheckBox(Foo.Bar)
@Html.Label(Foo.Bar)

However, I wanted to change the display name of several of the checkboxes, so I created a view model (to later add a display name attribute):

public class FooViewModel
{
     public string Bar
     {
         get { return Foo.Bar; }
     }
}

And modified the view:

@Html.CheckBox(Model.Bar)
@Html.LabelFor(m => m.Bar)

However, the view is now generating an error when rendering the checkbox:

String was not recognized as a valid Boolean

Note, that if I change the property name within the view model to anything other than “Bar” the view is rendered correct. EG:

public class FooViewModel
{
     public string WTF
     {
         get { return Foo.Bar; }
     }
}

@Html.CheckBox(Model.WTF)
@Html.LabelFor(m => m.WTF)

Can anybody explain to me why this error is occurring if my viewmodel property is named “Bar”?

Edit:
I have updated my question slightly seeing as how, i’m generating some confusion. The view is used as a search form and the checkboxes are simply used for selecting “search critera”.

I’m generating the checkbox in this fashion so the name / id of the checkbox is related to corresponding business logic within the controller.

I’m aware that code will not compile if property name / field name within the same class are identical. That is not the issue, as i’m simply initializing a property from constant within a different namespace.

  • 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-31T00:19:47+00:00Added an answer on May 31, 2026 at 12:19 am

    Using a different checkbox constructor resolves the issue:

    @Html.CheckBox(Model.Bar, false)
    @Html.LabelFor(m => m.Bar)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page model and a pages_controller within an admin namespace. My routes
So I'm trying to create a new feed within the Admin page and its
I would like to make an entire inline formset within an admin change form
I'm running a piece of code within a web page that queries the IIS
I have an admin page for a WordPress plugin that, thanks to the stackoverflow
You can see in this page: http://www.indiacustomercare.com/blogs/admin there is layout issue for some time
I'd like to create/update a sub-object within an admin edit dialog. I have a
I'm loading a simple page using: $.get('../admin/login.php', function(data) { $('#box-contents').html(data); }); Now, on this
I just set up an admin module with a grid view using the module
Consider: http://example.com/page.html?returnurl=%2Fadmin For js within page.html , how can it retrieve GET parameters? For

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.