MVC-3/jQuery: stop validating my checkbox

假如想象 提交于 2019-11-30 09:59:48

问题


I have MVC-3 user control (html helper & aspx view engine). Some how when I submit the form jQuery un-obtrusive validation fires up & requires me to check all checkboxes. How do I prevent it?

Further Info:

1) There is no required attribute in my model.

2) I am using this check-box inside telerik gridview

    namespace Alpha.Views
    {
        public class AlphaCheckBoxControl : ViewUserControl<AlphaCheckBox> { 
    }

    public class AlphaCheckBox
    {
        public bool isChecked;
        public string name { get; set; }
        public MvcHtmlString labelText;
        public bool readOnly;
        public bool visible { get; set; }

        public IDictionary<string, object> htmlAttributes()
        {
            var dict = new Dictionary<string, object>();

            if (readOnly) dict.Add(@"readonly", "readonly");
            if (readOnly) dict.Add("disabled", "disabled");
            return dict;
        }
    }  
}


<%@ Control Language="C#" Inherits="Alpha.Views.AlphaCheckBoxControl" 
        AutoEventWireup="True" CodeBehind="AlphaCheckBox.ascx.cs" %>


<tr>
      <td>
          <%= Html.Label(Model.name)%>
      </td>
      <td>
           <%= Html.CheckBox(Model.name, Model.isChecked, Model.htmlAttributes())%>
      </td>
  </tr>

来源:https://stackoverflow.com/questions/25831229/mvc-3-jquery-stop-validating-my-checkbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!