[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

enable/disable a drop down list based on selection of another drop down list

Posted on 2010-11-16
7
Medium Priority
?
558 Views
Last Modified: 2012-05-10
I am using .net 3.5 with C#. I have three drop down lists in a panel. I want to disable the second and the third drop down until a selection is made on the first. I tried the following:
disable second and third drop down lists on Page_Load. Then enable both of them in the OnSelectedIndexChanged event for the first drop down, but it does not enable them, probably because it is a client side event.

How can I accomplish this?

Thanks.
0
Comment
Question by:patd1
[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
  • 5
  • 2
7 Comments
 
LVL 8

Expert Comment

by:static-void
ID: 34149994
Is this winforms or webforms?
0
 

Author Comment

by:patd1
ID: 34150026
static-void:
Is this winforms or webforms?

This is webforms.
0
 

Author Comment

by:patd1
ID: 34150724
if I split them into two panels where panel 1 has first drop down list and panel2 ahs the the other 2 drop down lists, ho do I disable panel 2 until a selection has been made on panel 1?
0
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!

 
LVL 8

Expert Comment

by:static-void
ID: 34152315
Ok make sure your disabling code on page load is inside a if(!IsPostback){ } statement
0
 

Author Comment

by:patd1
ID: 34156874
Here's what I am doing and the process works, but it refreshes the whole page when I change the selection in my first drop down list (ddl), to enable the other two ddl s.
How can I make it refresh "panel3 only" when  selectedIndex gets changed on the first ddl.
I tried using AJAX update panel, but it starts giving me error when I add this line of code:
<%@ Register Assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxtoolkit" %> and <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

Error:Microsoft JScript runtime error: Sys.ArgumentTypeException: Object of type 'Object' cannot be converted to type 'Array'.
Parameter name: array
<asp:Panel ID="panel2" runat="server" GroupingText="CLIENT" EnableViewState="true" >
                    <table >
                        <tr>
                         <td class="cls">CLIENT</td><td><asp:DropDownList ID="adv_client" runat="server" OnSelectedIndexChanged="adv_client_SelectedIndexChanged" 
                             OnInit="adv_client_Init" AutoPostBack="true"></asp:DropDownList></td>
                        </tr>
                        </asp:Panel>
                    </table> 
                    <asp:Panel ID="panel3" runat="server" GroupingText="Facilities" EnableViewState="true" >
                    <table> 
                        <tr>
                            <td class="cls">Facility1</td><td><asp:DropDownList ID="adv_ord_ddl" runat="server" 
                                onselectedindexchanged="adv_ord_ddl_SelectedIndexChanged" 
                                 oninit="adv_ord_ddl_Init" ></asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td class="cls">Department</td><td><asp:DropDownList ID="adv_treat_ddl" runat="server" OnSelectedIndexChanged="adv_treat_ddl_SelectedIndexChanged"
                             OnInit="adv_treat_ddl_Init"></asp:DropDownList></td>
                        </tr>
                        </asp:Panel>
                    </table> 

 protected void Page_Load(object sender, EventArgs e)
    {.....

if (!IsPostBack)
        {
            this.panel3.Enabled = false;
...
}
}
protected void adv_client_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["adv_client"] = adv_client.SelectedItem.Value;
        if (adv_client.SelectedIndex > 0)
        {
            this.panel3.Enabled = true;
        }
    }

Open in new window

0
 

Accepted Solution

by:
patd1 earned 0 total points
ID: 34158791
setting ScriptMode="Release" in the script manager helped me get rid of that error.
0
 

Author Closing Comment

by:patd1
ID: 34186421
it works
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

650 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