How to remove span tag from WebControl when rendered

后端 未结 15 862
生来不讨喜
生来不讨喜 2020-12-31 03:34

When using an ASP.NET CheckBox (and in out case, inherited from a CheckBox) it renders a span around the checkbox input control, this span control

15条回答
  •  一整个雨季
    2020-12-31 04:15

                    
                /* remove the relative spam involving inputs disabled */
                $('input[name=""]').parent('.aspNetDisabled').each(function () {
                    var $this = $(this);
                    var cssClass = "onoffswitch-checkbox";
                    $('input[name=""]').addClass(cssClass).unwrap().parent('label[for],span').first().addClass('onoffswitch-checkbox');
                });
    

    This will allow you to use the check box normally, still have it call server side code, and use the toggle from bootstrap. (I'm using the Inspina theme but it should be the same format for other toggles)

提交回复
热议问题