• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

How to set a new color...

I want to set a new color. i.e "Red" to a Dropdown List when it's in disabled mode. By default it's disabled color is gray, so, how can I change it to Red?
0
NeGueSa
Asked:
NeGueSa
  • 4
  • 4
  • 2
  • +2
1 Solution
 
Steve BinkCommented:
Use a style entry.  Are you familiar with <STYLE> tags?
0
 
NeGueSaAuthor Commented:
No I'm not, but can you show me how to do it? I mean to change the color of the dropdown list.
0
 
kingsfan76Commented:
<select name=Sel1 style="BACKGROUND-COLOR:RED" disabled>

if you need to change the color dynamically using javascript, you can set it like this:

document.myForm.Sel1.style.BACKGROUND-COLOR = "RED";
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
NeGueSaAuthor Commented:
I'm sorry, but as I tell you I'm not familiar with java, so, The color I want to change is the forecolor of the dropdown list which is disabled, and let's say that my dropdown list is called "CustomList"
The code will be like this?
document.CustomList.Style.Color = "Red"
But this wil be for normal color, what about the disabled color?
0
 
kingsfan76Commented:
how does it determine if the select box is disabled or not?  is it throught some asp code?  if it's in asp code then it would be something like this:

<select name=CustomList <%if disabledYN="Y" then response.write("disabled style='BACKGROUND-COLOR:RED'")%>>


0
 
kiddangerCommented:
Just so you know...scripting CSS is different:

document.myForm.Sel1.style.BACKGROUND-COLOR = "RED";

Is not correct.

document.myForm.Sel1.style.backgroundColor='red';
or
document.myForm.Sel1.style.backgroundColor='#f00';

The rule is the - is removed and the following character is capitalized.

font-weight | fontWeight
background-color | backgroundColor
text-align | textAlign
border-width | borderWidth

For the OP: http://www.w3schools.com/css/default.asp

BTW... java != javascript
0
 
NeGueSaAuthor Commented:
I was trying to test these statements you gave me and nothing, it's giving me errors.
Please, could you be more specific?
This Dropdown List "CustomList" is disabled by default  and I puting it enabled/disabled in my vb code.
Do I have to put your [line of code] in the vb code or in the html page of the Web Form?
0
 
kingsfan76Commented:
can you show the vb code where you enable/disable CustomList?
0
 
NeGueSaAuthor Commented:
Yes of course here's the code :

    Private Sub ContDataGrid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContDataGrid.SelectedIndexChanged
        Dim SelRow As Integer = Me.ContDataGrid.SelectedIndex
        Dim contseq As Integer = CInt(Val(ContDataGrid.Items(SelRow).Cells(5).Text))

        Dim cm As New SqlCommand() 'Declaring Connection
        Dim flg As String 'Declaring Result

        cm.CommandText = "SELECT Name, Acc , Email, Method, Sheet FROM  Contact WHERE Seq ='" & contseq & "'" 'Making the Query
        cm.Connection = SqlCon 'stablishing connection
        SqlCon.Open() 'opening connection

        Dim dr As SqlDataReader = cm.ExecuteReader 'reading
        While dr.Read
            If IsDBNull(dr.Item(0)) = False Then
                flg = dr.Item(0) 'assigning value
                If IsDBNull(dr.Item(1)) = False Then
                    CustomList.SelectedIndex() = Me.Cboctype.Items.IndexOf(Me.Cboctype.Items.FindByValue(Trim(dr.Item(1))))
                    Me.lblctype.Visible = True
                    Me.CustomList.Visible = True
                Else
                    Me.lblctype.Visible = False
                    Me.CustomList.Visible = False
                End If
            Else
                'no users
                'Put here N/A for all values
                Exit While 'exiting
            End If
        End While
        dr.Close() 'closing reading
        dr = Nothing 'assigning value 0
        SqlCon.Close() 'closing connection
    End Sub
0
 
kingsfan76Commented:
i see... you should have stated it is asp.net coz by default we all assume it is classic asp.  I'm less familiar with .net, but you might try this and see if it works:

Me.CustomList.Style("BACKGROUND-COLOR") = "RED"

here's a link to some samples on how to apply style in .net
http://www.dotnetjunkies.com/quickstart/aspplus/doc/webtemplates.aspx

sorry i don't have a .net compiler right now at work so i can't be sure if the solution works.  
0
 
WMIFCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.  I will make a recommendation to the moderators on its resolution in a week or two.  I appreciate any comments that would help me to make a recommendation.

Unless it is clear to me that the question has been answered I will recommend delete without refund of points.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade.  It is assumed that any participant not responding to this request is no longer interested in its final disposition.

If the user does not know how to close the question, the options are here:
http://www.experts-exchange.com/help.jsp#hs5

WMIF
EE Cleanup Volunteer
0
 
WMIFCommented:
I am leaving the following recommendation for this question in the Cleanup topic area:
Delete - No refund

Any objections should be posted here in the next 4 days.  After that time, the question will be closed.

WMIF
EE Cleanup Volunteer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now