本文介绍了呈现时如何从WebControl中删除span标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当使用ASP.NET CheckBox(在少数情况下,继承自CheckBox)时,它将在复选框输入控件周围呈现一个跨度,该跨度控件会影响jQuery脚本.
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 is affecting jQuery scripts.
渲染时是否可以删除该跨度?
Is it possible to remove this span when rendering?
推荐答案找到了这个有用的提示:
Found this useful tip:
在后面的代码中,使用InputAttributes而不是Attributes.
In Code Behind, use InputAttributes instead of Attributes.
例如,键入:
chk.InputAttributes.Add("onchange", "updateFields()")代替此:
chk.Attributes.Add("onchange", "updateFields()")或代替内联声明:
<asp:CheckBox ID="chk" runat="server" onchange="updateFields()" />最后两个会引起环绕间距.
The last two will cause the wrapping span.
更多推荐
呈现时如何从WebControl中删除span标签
发布评论