开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜