使复选框asp.net的MVC 2和jQuery禁用 [英] make checkbox disabled in asp.net mvc 2 and jquery
本文介绍了使复选框asp.net的MVC 2和jQuery禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到了我想要被禁用复选框?我使用asp.net MVC 2和jQuery。
<%= Html.EditorFor(P => p.flag)%GT;
公共类为MyModel
{
公共BOOL标志{获取;设置;}
}
解决方案
您可以使用jQuery使用禁用的复选框
$('#标志')ATTR(禁用,真正的)。
或者如果你想这样做在服务器端,你必须退回到checkboxfor帮手像
<%:Html.CheckBoxFor(X => x.flag,新{禁用=禁用})%GT;
或者你可以写,可以消耗 Html.EditorFor
i got a checkbox that i would like to be disabled ? i am using asp.net mvc 2 and jquery.
<%= Html.EditorFor(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
这篇关于使复选框asp.net的MVC 2和jQuery禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文