开发者

make checkbox disabled in asp.net mvc 2 and jquery

开发者 https://www.devze.com 2023-03-18 18:39 出处:网络
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) %>

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

精彩评论

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

关注公众号