Solved

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

Posted on 2013-01-31
7
1,267 Views
Last Modified: 2013-03-01
Hi,

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:DropDownList>
<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)
    {
        try
        {
            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;
        }
    }//CustomValidatorDDScriptType_ServerValidate

Open in new window

0
Comment
Question by:Saroj13
7 Comments
 
LVL 11

Expert Comment

by:mcnute
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

0
 

Author Comment

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

Author Comment

by:Saroj13
ID: 38840326
Sorry I meant to say dropdown border color not change if I use IE7. If IE browser is IE8, then its fine.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 41

Expert Comment

by:guru_sami
ID: 38840770
0
 

Author Comment

by:Saroj13
ID: 38840974
Hi,

In IE8 , its working perfectly fine.

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

Expert Comment

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

Accepted Solution

by:
informaniac earned 500 total points
ID: 38842713
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
exporting html table data 4 27
Html Newline 7 20
JavaScript Sort Ordering and Choice Limiting 5 20
Only allow one check box 17 25
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

839 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