如何为启用 ASP.NET 主题的控件设置多个 cssclass 名称?
CSS 支持多个类名:
<hwc:DropDownList ID="ddlRoomType" runat="server" class="invisible blue" EnableTheming="true" />
皮肤文件:
<%-- Default dropdown appearance --%>
<asp:DropDownList runat="server" CssClass="dropDownList" AutoPostBack="true"/>
而asp.net 主题为我们提供了额外的皮肤和属性抽象层。所以我谈论的是经典的 CSS 样式和 ASP.NET 主题组合场景。
但是,当在启用了 ASP.NET 主题的情况下手动提供 CssClass(或类)属性时,您必须选择哪个属性将覆盖另一个属性。
我们如何将手动输入的类名与 asp.net 主题创建的动态类名结合起来生成如下所示的 html 输出;
<select id="ctl00_Content_ddlRoomType" class="invisible blue dropDownList">
<option value="0">- Select Room -</option>
<option value="9">Single Room</option>
</select>
我找不到任何 .net 主题类来重写以实现另一个主题逻辑。 有什么想法吗?谢谢。
CSS supports multiple class names:
<hwc:DropDownList ID="ddlRoomType" runat="server" class="invisible blue" EnableTheming="true" />
Skin file:
<%-- Default dropdown appearance --%>
<asp:DropDownList runat="server" CssClass="dropDownList" AutoPostBack="true"/>
And asp.net theming provides extra skinning and attribute abstraction layer for us. So i'm talking about classic css styling and asp.net theming combined scenario.
But when it comes to giving a CssClass (or class) attribute manually with asp.net theming enabled, you have to make a choice which one is to override another.
How can we combine manually entered class names with dynamic class name created by asp.net theming to generate the html output like below;
<select id="ctl00_Content_ddlRoomType" class="invisible blue dropDownList">
<option value="0">- Select Room -</option>
<option value="9">Single Room</option>
</select>
I can't find any .net theming class to override to implement another theming logic.
Any ideas? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
标准运行时不支持组合 CSS 类。
但是,使用控制适配器添加应该非常容易。您可以使用类似
CssClass="+dropDownList"
的语法将该类添加到任何现有的默认值中。控件适配器将查找加号,并相应地设置CssClass
属性。或者(可能更容易),您可以覆盖您感兴趣的现有类,并修改
CssClass
属性以按您想要的方式工作。Combining CSS classes isn't supported by the standard runtime.
However, it should be pretty easy to add, using a control adapter. You might use a syntax something like
CssClass="+dropDownList"
to add the class to any existing defaults. The control adapter would look for the plus sign, and set theCssClass
property accordingly.Alternatively (and probably easier), you could override the existing classes you're interested in, and modify the
CssClass
property to work like you want.