[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2013-01-31
7
Medium Priority
?
1,425 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
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

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.

Question has a verified solution.

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

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
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
Course of the Month19 days, 18 hours left to enroll

872 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