views:

152

answers:

1

Css supports multiple class names;

    <hwc:DropDownList ID="ddlRoomType" runat="server" class="invisible blue" EnableTheming="true">
    </hwc:DropDownList>

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.

A: 

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 the CssClass 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.

RickNZ
In order to concatenate class names, first i have to get the CssClass value (expression like "dropdownlist+") from the dropdown control class. But in theming enabled mode i can only get the replaced value (dropdownlist) even on control's OnInit event. Theming event works and replaces values before the control and page class events i guess. So i need to catch some events before theming operation occurs. Then i can implement your solutions easily.Thanks.
Gökhan Ercan
You might start by switching to a StyleSheetTheme instead of a regular Theme. The former allows you to override skin properties on the page, where the latter does the reverse. You could always set the CssClass property programmatically on your page. To automate it, you will need either a control adapter or a derived class, as I explained in my answer.
RickNZ