开发者

How to disable radiobuttons and checkboxes produced by HtmlHelper methods in ASP.NET MVC?

开发者 https://www.devze.com 2022-12-31 09:50 出处:网络
I have a series of pages (in a wizard type application). After collecting user\'s inputs here and there, I\'d like to display a summary in a single page. I don\'t want the users to modify information

I have a series of pages (in a wizard type application). After collecting user's inputs here and there, I'd like to display a summary in a single page. I don't want the users to modify information on that page, just to visualize them. Otherwise, he they go back to the previous pages to do so开发者_运维百科.

To obtain that, I use Html.Encode(Model.field) to replace textbox. But I don't want to replace checkboxes and radiobuttons; I'm gonna need to disable them. But,

How do I disable Radiobutton and checkboxes when using HtmlHelper methods?

<%Html.CheckBox("MyCheckBox")%>

or

<%Html.RadioButton("MyRadioButton")%>

Thanks for helping


Add the HTML attribute disabled:

<%: Html.CheckBox("MyCheckbox", new { disabled = "disabled" }) %>
<%: Html.RadioButton("MyRadioButton", value, new { disabled = "disabled" }) %>
0

精彩评论

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