Share via


CSS with AjaxControlToolkit:ComboBox

Question

Wednesday, December 29, 2010 12:58 PM

Hi

I was trying to use CssClass="WindowsStyle" with the following CSS. Its working fine if WindowsXP theme is selected but when the theme is changed it looks odd (different from other controls).

I wish to have the ComboBox similar to the style used by other controls. Please give me the solution for this issue.

I understand the issue is with the button(background-image: url(../images/windows-arrow.gif);) but what could be the alternate solution?

 

 

CSS used

.WindowsStyle .ajax__combobox_textboxcontainer input
{
    border: solid 1px #7F9DB9;
    border-right: 0px none;
    padding: 1px 0px 0px 5px;
    font-size: 13px;
    height: 21px;
}
.WindowsStyle .ajax__combobox_buttoncontainer button
{
    border: 0px,none;
    background-image: url(../images/windows-arrow.gif);
}
.WindowsStyle.ajax__combobox_itemlist
{
    margin: 0px;
    padding: 0px;
    cursor: default;
    list-style-type: none;
    text-align: left;
    border: solid 1px ButtonShadow;
    background-color: Window;
}
.WindowsStyle .ajax__combobox_itemlist li
{
    white-space: nowrap;
    padding: 0 3px 0 2px;
}
.ajax__combobox_itemlist
{
    margin: 0px;
    padding: 0px;
    cursor: default;
    list-style-type: none;
    text-align: right;
    border: solid 1px ButtonShadow;
    background-color: Window;
    font-weight: normal;
    font-size: 8pt;
    color: black;
    font-family: Arial, helvetica, 'MS Sans Serif';
    width: 100%;
}

 

All replies (7)

Monday, January 3, 2011 8:24 PM âś…Answered

ASP.NET applications can let you access registry information of your Windows, where the selected theme is possibly found. This is IE-only, not cross-browser.

You may have a look at this reference http://todotnet.com/post/2003/10/02/Can-ASPNET-read-the-registry-or-not.aspx 

Also, you would need to look at the application's trust level, for which the access of registry would be effective. For your reference, http://msdn.microsoft.com/en-us/library/87x8e4d1

At default level for general users, I am afraid it is not likely to have your ASP.net applications know what theme these users are using.

 

 


Thursday, December 30, 2010 8:40 PM

Hello

It may be that other styles do not override your WindowsStyle

For other CSS files, You may write

.OtherStyle .ajax__combobox_buttoncontainer button   

{   

    border: 0px,none;   

    background-image: none;

}


Friday, December 31, 2010 6:18 AM

Hi

Thanks for your response.

But how would the control know if the Windows theme is changed. For eg. Background color for WinXP theme is blue but Windows classic is some other color. We cannot come back to the code everytime and change the style everytime.

 

Regards

Jagdish 


Sunday, January 2, 2011 10:21 PM

Suppose that you are using a button to alter the theme.

Then, at your code behind,

        protected void Button1_Click(object sender, EventArgs e)
        {

               ComboBox1.CssClass = "OtherStyle";
        }


Monday, January 3, 2011 6:01 AM

I am not using any button to change the Theme and no way the program would know that the Theme is changed.

The user would change the Theme using "Display Properties" of Windows. In this case my program has ComboBox in different color(or theme) than others(normal webcontrols) on the screen.

 


Monday, January 3, 2011 6:01 AM

I am not using any button to change the Theme and no way the program would know that the Theme is changed.

The user would change the Theme using "Display Properties" of Windows. In this case my program has ComboBox in different color(or theme) than others(normal webcontrols) on the screen.

 


Monday, January 10, 2011 1:57 AM

Hi

Sorry for late reply, as you said the general users may not have access to the registry. Why is this not behaving as a normal asp combobox(DropdownList). When I dont need to change any css for normal DropdownList, why should I explicitly change the css when windows theme is changed.

I think this AjaxComboBox should provide the same look and feel as normal DropdownList and I think this is a bug here.