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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:49:02+00:00 2026-06-14T15:49:02+00:00

In my project I have a string field in the view model to display

  • 0

In my project I have a string field in the view model to display in a form and post back to the controller.

However for some reason, I’d like to display a checkbox, and retrieving string “True”/”False” from user input

I’ve searched through the internet and found this
How to render a model property of string type as checkbox in ASP.NET MVC
which leverage the editor template and achieve my need.

My question is that how do this be achieved, because in the editor template, I can only see it how to interpret the string to a checkbox, but it never explain or show how the checkbox value will be bind back to the string field with “True”/”False”.

What should I do if I wanted “Yes”/”No” instead of “true”/”false”, are there any converter that I need to make to parsing the checkbox to string?

Sorry for my bad English and lack of mvc knowledge, I just started MVC and web development for a few days.

UPDATE:
1. I am using ViewModel to bind with the forms, so I need something like Html.CheckBoxFor(x=>x.value)
while x.value is a string, obviously it is not possible with the default CheckboxFor

  • 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-14T15:49:03+00:00Added an answer on June 14, 2026 at 3:49 pm

    I think what you are asking is how to save the value back into your database, which is more of a back-end C# or VB question.

    As you know, when you submit a form on an HTML page, if a checkbox is ticked, it’s value will be passed in the POST parameters back to the server:

    front-end HTML:

    <input type="checkbox" name="theCheckBox" value="Yes" />
    

    back-end C# in Page_Load() or similar

    if(Request.Form["theCheckBox"] == "Yes") {
        // save value "Yes" into database
    }
    

    just remember that if the checkbox is NOT TICKED, Request.Form[“theCheckBox”] will be null

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

Sidebar

Related Questions

I have a Django application which includes a custom model field (and accompanying form
I have a PaartialView declared like this: @model IEnumerable<mvc1.Models.ProjectDetailModel> @using (Html.BeginForm()) <form method=get action=EditProject
In my Rails project I have the following code: auto_link( h( wrap_long_string(post.text,50) )).gsub(/\n/,<br />)
In my Values folder for my project, I have a string array named currency_avatar.
I'm working on code for a Java project, I currently have replaceAll(String, int) in
Let's say I have two simple models project t.string :title vote t.references :project t.integer
I have string like this: G:\Projects\TestApp\TestWeb\Files\Upload\file.jpg How can I remove all text before Files
In my project I have to display a list of reports so in the
I have a strongly typed razor view for a model in my MVC 3
I have nested model as following Project model has_many keywords and keyword belongs_to project

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.