?
Solved

apply skinfile to drowdownlist

Posted on 2013-02-06
3
Medium Priority
?
243 Views
Last Modified: 2013-02-14
I can apply skin to txtbox, but on dropdownlist it won't work. I am not sure why?


From Skinfile

asp:TextBox runat="server" SkinID="txtcity" ForeColor="Blue"></asp:TextBox>
<asp:DropDownList runat ="server" SkinID ="ddlstate" Forecolor ="Red"></asp:DropDownList>


aspx page

<asp:DropDownList ID="ddlstate" runat="server" Width="100px" TabIndex="9" Enabled="false" SkinID="ddlstate">
<asp:TextBox ID="txtCity" runat="server" Width="360px" TabIndex="8" MaxLength="30" ReadOnly="true" SkinID="txtcity"></asp:TextBox>
0
Comment
Question by:VBdotnet2005
  • 2
3 Comments
 
LVL 26

Expert Comment

by:Alan Warren
ID: 38862068
This works ok, created a theme "Theme1" added a SkinFile "SkinFile1.skin"
Contents of Skinfile1.skin:
<asp:DropDownList runat="server" BackColor="Blue" ForeColor="Red" SkinId="dropdownlistBlue" />

Open in new window

Page sample:
<%@ Page Language="VB" title="MyGridview" EnableTheming="true" Theme="Theme1"%>

<!DOCTYPE html>

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList SkinID="dropdownlistBlue" ID="DropDownList1" runat="server">
            <asp:ListItem></asp:ListItem>
            <asp:ListItem Value="1">Choice 1</asp:ListItem>
            <asp:ListItem Value="2">Choice 2</asp:ListItem>
        </asp:DropDownList>

    </div>
    </form>
</body>
</html>

Open in new window

Alan
0
 

Author Comment

by:VBdotnet2005
ID: 38862141
If the dropdownlist is set enable = "false", we can't change forecolor, correct? It will remains gray, no matter ?
0
 
LVL 26

Accepted Solution

by:
Alan Warren earned 2000 total points
ID: 38862447
Hi VBdotnet2005,
couldn't find a way to change the forecolor for a disabled dropdownlist, backcolor, no problem.

The skinfile can have a CssClass, the CssClass can address styling for enabled and disabled.
Skinfile:
<asp:DropDownList runat="server" CssClass="styled-select" SkinId="dropdownlistBlue" />

Open in new window

Sample .aspx page styling dropdownlist, enabled and disabled:
<%@ Page Language="VB" title="MyDrowdownList" EnableTheming="true" Theme="Theme1"%>

<!DOCTYPE html>


<script runat="server">

    Protected Sub Button1_Click(sender As Object, e As EventArgs)
        Me.DropDownList1.Enabled = Not Me.DropDownList1.Enabled
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">

        .styled-select:enabled, .styled-select:disabled {
            background: transparent;
            color:black;
            background-color:yellow;
            width: 268px;
            padding: 5px;
            font-size: 16px;
            line-height: 1;
            border: 0;
            border-radius: 0;
            height: 34px;
            -webkit-appearance: none;
        }
        .styled-select:disabled {
            background-color:greenyellow;
            color:dimgray;
        }
 


    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList CssClass="styled-select" ID="DropDownList1" runat="server" >
            <asp:ListItem></asp:ListItem>
            <asp:ListItem Value="1">Choice 1</asp:ListItem>
            <asp:ListItem Value="2">Choice 2</asp:ListItem>
        </asp:DropDownList>
        <br /><br />
        <asp:Button ID="Button1" runat="server" Text="Toggle dropdown enabled" OnClick="Button1_Click" />


    </div>
    </form>
</body>
</html>

Open in new window

Alan ";0)
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Screencast - Getting to Know the Pipeline
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question