Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Asp.net Dropdownlist border color not changing in case of iis7.

Posted on 2013-01-31
Medium Priority
Last Modified: 2013-03-01

I am using asp.net dropdownlist and custom validator and if the dropdownlist is having nothing selected, then on button submit, I am changing the border color of dropdownlist from grey to red.

border color not changing in IIS7.

<asp:DropDownList ID="ddlScriptType" CssClass="Dropdown-Admin-req" AppendDataBoundItems="true" runat="server" DataSourceID="ScriptTypeDataSource" DataTextField="TypeName" DataValueField="ScriptType_ID" SelectedValue='<%# Bind("ScriptType_ID")%>' Width="100px"
BorderStyle="Solid" BorderWidth="1pt"    >
<asp:ListItem > </asp:ListItem>
<asp:CustomValidator ID="cvScriptType" runat="server" ErrorMessage=""  ControlToValidate="ddlScriptType" ClientValidationFunction="ValidateDDScriptType"  
    OnServerValidate="CustomValidatorDDScriptType_ServerValidate"  ValidateEmptyText="True"></asp:CustomValidator>

       function ValidateDDScriptType(source, args) {
           var is_valid1 = $("#ddlScriptType").val() != "";
           $("#ddlScriptType").css("background-color", is_valid1 ? "white" : "#FFEEEE");
           $("#ddlScriptType").css("border-color", is_valid1 ? "#cccccc" : "#FF0000");
           args.IsValid = is_valid1;

   protected void CustomValidatorDDScriptType_ServerValidate(object source, ServerValidateEventArgs args)
            FormViewRow row = InsertScriptFormView.Row;
            DropDownList ddScriptType = (DropDownList)row.FindControl("ddlScriptType");
            bool is_valid1 = ddScriptType.SelectedValue != "";
            System.Drawing.Color selcolor = System.Drawing.ColorTranslator.FromHtml("#cccccc");
            System.Drawing.Color selbordercolor = System.Drawing.ColorTranslator.FromHtml("#FF0000");
            System.Drawing.Color selbackgroundcolor = System.Drawing.ColorTranslator.FromHtml("#FFEEEE");
            ddScriptType.BackColor = is_valid1 ? System.Drawing.Color.White : selbackgroundcolor;
            ddScriptType.BorderColor = is_valid1 ? selcolor : selbordercolor;
            args.IsValid = is_valid1;
        catch (Exception ex)
            throw ex;

Open in new window

Question by:Saroj13
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 11

Expert Comment

ID: 38840005
This is nothing related to your webserver, since this is javascript and is happening clientside.

Change your jquery accordingly:

 function ValidateDDScriptType(source, args) {
           var is_valid1 = $("#ddlScriptType").val();
           if (is_valid !='') {
                   $("#ddlScriptType").css("background-color",  "white");
                   $("#ddlScriptType").css("border-color", "#cccccc");
           } else {
                    $("#ddlScriptType").css("background-color", "#FFEEEE");
                    $("#ddlScriptType").css("border-color", "#FF0000");
           args.IsValid = is_valid1;

Open in new window


Author Comment

ID: 38840101
If i use iis8, then border color of dropdownchange from greyto red

Author Comment

ID: 38840326
Sorry I meant to say dropdown border color not change if I use IE7. If IE browser is IE8, then its fine.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Author Comment

ID: 38840974

In IE8 , its working perfectly fine.

I am using IE7, dropdownlist border not changing from grey to RED.
LVL 41

Expert Comment

ID: 38840982
Yes but try those solutions for IE7 as well.
LVL 20

Accepted Solution

informaniac earned 1500 total points
ID: 38842713

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

636 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