Adding custom attributes to an asp:CheckBox control

后端 未结 2 657
逝去的感伤
逝去的感伤 2020-12-17 17:06

I am trying to add a custom data-required attribute to an asp Checkbox control, it works fine for all other controls I\'ve used it on, but on checkboxs it renders the checkb

相关标签:
2条回答
  • 2020-12-17 17:06

    use InputAttributes

    0 讨论(0)
  • 2020-12-17 17:29

    Here is the code I have used:

    cb.InputAttributes.Add("data-group", "chkbox");
    

    Then you can use JQuery to target all check-boxes.

     $("*[data-group='chkbox']").prop("checked", true);
    
    0 讨论(0)
提交回复
热议问题