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!
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:
It's shorter and it will produce code like that:
And BTW, there is a helper method
Html.CheckBoxto create checkbox in your view and in second parameter you can indicate if you want it to be checked:And that will rendrer this:
Try it on your own.