开发者

How can I make my own check box in MVC?

I would love to use the:

Html.EditorFor(model => @Data.Test.Correct)

To create a checkbox.

However the source of my data is different from the data that needs to be updated. I know this may sound confusing but 开发者_StackOverflow社区I get my data from a LINQ select query and then need to update in a different place.

The only way around this seems for me to hand code the HTML for the checkbox. But can someone give me an example of how I do this. For example, how can I code in the setting of checked=true?


You may write HTML codes like below to create a selected or unselected checkbox

<input type="checkbox" name="option1" value="1" checked="checked" />
<input type="checkbox" name="option2" value="2" />

But you will need to write additional code manually to determine which checkbox should be selected, if your checkbox is dynamic generated or being filled in with stored data.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜