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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:06:43+00:00 2026-06-18T05:06:43+00:00

bool isChecked = false; <input type=checkbox name=x checked=@isChecked /> In MVC 4, The above

  • 0
bool isChecked = false;
<input type="checkbox" name="x" checked="@isChecked" />

In MVC 4, The above code will be generate as

<input type="checkbox" name="x" />

But in MVC 3,Need to write like this:

bool isChecked = false;
@if(isChecked)
{
   <input type="checkbox" name="x" checked="checked" /> 
}
else
{
    <input type="checkbox" name="x" /> 
}

If we are Microsoft developers, Which assembly need to modify and how to modify it?
How to customize the upgrade code?
Plase help me,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-18T05:06:44+00:00Added an answer on June 18, 2026 at 5:06 am

    To be honest I don’t really understand the question after those code blocks, but I can say that you can use inline condition in your views in ASP.NET MVC3. Something like that for example:

    bool isChecked = false;
    <input type="checkbox" name="x" @(isChecked ? "checked=checked" : "") />
    

    It’s shorter and it will produce code like that:

    <input type="checkbox" name="x">
    

    And BTW, there is a helper method Html.CheckBox to create checkbox in your view and in second parameter you can indicate if you want it to be checked:

    @{bool isChecked = false;}    
    @Html.CheckBox("x", isChecked)
    

    And that will rendrer this:

    <input id="x" type="checkbox" value="true" name="x">
    <input type="hidden" value="false" name="x">
    

    Try it on your own.

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

Sidebar

Related Questions

net mvc3 application I have a checkbox: <input type=checkbox id=daStores name=CheckBox1 onclick=filter() /> How
i have a simple checkbox <CheckBox IsChecked={Binding ForceInheritance}/> In Code i have a class
I have a checkbox which i need to bind to a bool in the
I want to get a checkbox value from a datagridview(True/False) but I always get
I have a checkbox with its IsChecked property bound to a nullable bool. When
I have simplified example: XAML: <CheckBox IsChecked={Binding Path=IsSelected, Mode=TwoWay} Name=cb /> <Button Name=button1 Click=button1_Click
the XAML of my window: <ListView Grid.Row=0 Name=files> <ListView.Resources> <DataTemplate x:Key=CheckboxTemplate> <CheckBox IsChecked={Binding Save,
bool hasDuplicate = false; int[] a = new int[] {1, 2, 3, 4}; int[]
bool isValid = false; string username = someadmin; If( !String.IsNullOrEmpty(username) && !( username.IndexOf(admin) !=
bool is_something_ok(int param,SomeStruct* p) { bool is_ok = false; // check if is_ok if(is_ok)

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.