make checkbox disabled in asp.net mvc 2 and jquery
i got a checkbox that i would like to be disabled ? i am using asp.net mvc 2 and jquery.
<%= Html.EditorFor开发者_Python百科(p=>p.flag) %>
public class MyModel
{
public bool flag {get;set;}
}
you can either use jquery to disable your checkbox using
$('#flag').attr('disabled', true);
or if you want to do it on server side you have to fall back to checkboxfor helper like
<%:Html.CheckBoxFor(x => x.flag, new { disabled = "disabled" }) %>
or you can write your own editor template that can consume additionalViewData parameter of Html.EditorFor
精彩评论