开发者

MVC3 Check a checkbox on page load

I am working开发者_如何学JAVA on an MVC3 app that has several forms. When I get to one form if a variable (ViewData) is true I want to check a checkbox by default but I have no idea how to do this. Any help?

Thanks,

Rhonda


I would recommend using Html.CheckboxFor(). Here's a simple example. If you have a model with a property IsSet then you can do this:

@Html.CheckBoxFor(m => m.IsSet)

Good luck.


With the HtmlHelper extension :

<% Html.CheckBox("name", bool.Parse(ViewData["isChecked"])) %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜