?
Solved

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

Posted on 2013-01-31
7
Medium Priority
?
1,335 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
[X]
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
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 1500 total points
ID: 38842713
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
Suggested Courses

762 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