Hide dropdown list based on other dropdown list selection

Hi,

i have an aspx page with a form. I want to hide dropdown list b depending on what is selected for dropdown list a.

I need to do this client side

Im new to this so any assistance would be appreciated.

Thanks in advance

0
tango2310
9/7/2007 6:14:15 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

6 Replies
1245 Views

Similar Articles

[PageSpeed] 47

 

could you explai briefly about your requirements?

you want to maske dropdownlist b as invisible if you select any item on dropdownlist a?

or you want to make it invisible for a specific item?

 

0
Tweety
9/7/2007 9:24:31 AM

Hi,

    Change the visibility of dropdownlist as false on selected index change.

Private Sub ddl_a_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddl_a.SelectedIndexChanged

if (ur condition) Then
ddl_b.Visible = False
End if

End Sub

.........I think this is what u wanted if i have understood u right..

Thanks,
Suman

 

0
suman
9/7/2007 9:27:43 AM

yes, as suman said..jus change the visibility style

in your page load make all dropdown list as visible...

and in dropdown list selected indexchange ...juc change the dropdownlistb.visible=false

and dont forget to set in dropdownlista property autopostback as true

 

0
Tweety
9/7/2007 9:46:18 AM

If i would be on u, i would have rely on JS, there is no need to post complete form for sake of hiding another dropdown. Just add an attribute for sorce ddl "onChange" javascript event and call a javascript finction and then hide the other ddl usein

document.getElemtByID('targetDDlID').style.display='block' ;


No body is perfect, I'm nobody
0
saifi_hasan
9/7/2007 10:16:10 AM

Thanks everyone for the valued responses.

The javascript version look like its the way to go.

Could you please be a little more specific as i am inexperienced.

I had some javascript functions working nicely but since of gone to aspx pages using .net controls (in vs2005) i can quite get javascript working.

Thnaks in advance

0
tango2310
9/8/2007 7:53:18 AM
try this out.... 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript" language="javascript">
    function test()
    {
        if(document.getElementById('<%=DropDownList1.ClientID%>').value == "Select")
            document.getElementById('<%=DropDownList2.ClientID%>').style.display = "none";
        else
            document.getElementById('<%=DropDownList2.ClientID%>').style.display = "block";
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">        
        <asp:DropDownList ID="DropDownList1" runat="server" onchange="test()">
            <asp:ListItem>Select</asp:ListItem>
            <asp:ListItem>some item A</asp:ListItem>
            <asp:ListItem>Some Item B</asp:ListItem>
        </asp:DropDownList>
        <asp:DropDownList ID="DropDownList2" runat="server">
        </asp:DropDownList>
    </form>
</body>
</html>
hope it helps./. 
 

Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
9/8/2007 8:14:28 AM
Reply:

Similar Artilces:

Filling a dropdown list, based on a selection from another dropdown list
This seemed like a simple venture, and may be, but with my limited asp.net knowledge, I am having a problem... Basically, I have a page that is gathering information. I want a user to be able to select a value from a dropdown list... On Auto postback I would like to make a second listbox visible and bind data to it based on the selection from the first. (While keeping the value of the first listbox available) Right now I am filling my dataset with the tables used in the page load event and setting my second listbox.visible to false. in the SelectedIndex_change event of the first...

Populate dropdown list based on selected value in another dropdown list
I have a datagrid (grdCar) that contains two dropdown listboxes (ddlCarManf and ddlCar). When the user clicks the "Edit" link and places the grid into edit mode, they select a value in ddlCarManf. Based on the selected value in ddlCarManf, I need to then populate ddlCar with a list of cars for which the selected manufacturer makes (I'm using ddlCarManf.SelectedValue to query the database).  I bind my datagrid in the page_load event as: If Not Page.IsPostBack Then    BindGrid() End If Here is my control (ddlCarManf) as is appears within grdCar in ...

automatically generating content in a dropdown list based on the selection of another dropdown list
hi i currently have a "categories" dropdown list i'm using to help filter data in a datagrid (have it setup using data and table adapters). i've introduced another dropdown list (called subcategories) to filter the datagrid so it only displays records that fit in both the category and subcategories.it all works fine, but i'm wanting to set it so the subcategories dropdown list gets generated on the client-side depending on the category selected. does anybody have any quick tutorials or a quick explination on how i could do this? am i missin...

Cascading Dropdown List
Hi, First post so hello and need some help with an issue I have been dealing with.  I have an intranet page I created in ASP.NET using C# .NET 3.5 with a few Ajax Extenders including 3 Cascading Dropdown Lists. Now I have used the Cascading dropdown lists for my own purposes i.e they do not actually cascade their results to another dropdown list, the reason I did this was due to the having a User Control that contains an update panel and other bits i.e I didn't want the control/page posting page (something that happens when you click on a regular dropdown list). Everything is wor...

Populate a Dropdown List based on the value of another Dropdown List
 Hi ALL,    I have two Dropdown List.I need to Populate second Dropdown List based on the value of first Dropdown List.I am n't using Update Panel.Pls suggest me RegardsSri ASP.NET AJAX Cascading DropdownDarrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!   just populate second dropdown in SelectedIndexChanged event of the first dropdown. Muhammad ShoaibSoftware Engineer,Lahore, Pakistanwww.heartofpakistan.com (U/C)--------------------------------Mark it as ANSWER if it Helps U   Check out this link with co...

Using a selection from a dropdown list to fill in a second dropdown list.
Hi,  I am new to the web programming area and looking for some help.  I have a situation where, like i said in my subject trying to base the list in the ddl2, to be based on the selection from ddl1.  What do i all need to include to do this.  As of now, I have two seperate SQL data sources, with the first one I have it just selecting from our database.  For the second list, I have a second sql data source that does a selection of a different column from teh same database but in the where clause have a parameter that will equal the selection from teh first.. &n...

one dropdown list affecting another dropdown list vb.net
I am desgining a website using VB.NET wherein the data items of one dropdown list depends on the selection of a data item in the previous dropdown list something similar to selection of country USA from 1st dropdown list...triggers 2nd dropdown with list of states in USA How can this be accomplished.... Any help will be appreciated... Thanks & Best Regards... hi boy,first I suggest turn on auto postback on first dropdownlist. In select index changes(first dropdownlist) - select value on second dropdownlist My blog is here.Please remember to 'Mark as Answer' i...

Selection in one dropdown list effecting the visibility of another dropdown list
I have two drop down lists. They are not databound. We'll called them dropdownlist1 and dropdownlist2.Basicly, I want people to choose an object in the first dropdownlist. Depending on their selection, it will make certain items in dropdownlist2 invisible.Currently my thought is to have something in the lines of the following (In the dropdownlist1 - SelectedIndexChanged - Postback being set to Auto)if dropdownlist1.text = "Such and such" then(this is where I would declare which options are available)However, I do not know the proper syntax of saying make the following item...

Filter dropdown list from another dropdown list
Help Please!!! I am trying to filter the data in a dropdown list from information chosen in another dropdown list. 1st table has modification types, 2nd table has modifications. When the user chooses the modification type needed, then only those modifications should appear in the 2nd list. mydata7 = New SqlDataAdapter("Select * from ModificationList ", myconnection) ds7 = New DataSet mydata7.Fill(ds7, "table") Dim dr7 As DataRow ddlModification.Items.Add("Please select Modification ...") ...

Dropdown list bound to another dropdown list
I have two dropdown lists on my page. The first contains a list of names and the second contains a list of hardware devices. My problem is: When i choose a name from the first dropdown i need the second to become populated with their related devices. This works fine, however if i then change the name in the first dropdown list, it adds another set of devices to the devices dropdown list. The way i want it to work is to refresh the devices dropdown when the name is changed. So that only that persons related devices show up (in the second dropdown)  Any help would be much apprecia...

populate a dropdown list on the basis of other dropdown list
I need to populate a dropdown list on the basis of other dropdown list. Both dropdwon list are datasourced with SQL datasource. I tried the SQL datasource where query . but it will need a post back. I dont want my form to be postback. I guess this is what AJAX is for but i really dont know how to get this with AJAX in a simple and quick way..... or it is not simple and quick ????Mark as answer if anybody's post has helped you It can be simple and quick.  See this video:http://www.asp.net/learn/ajax-videos/video-77.aspx And also the tutorial on how to use the Cascading Dropdow...

Load Text box of one web form with selected list item of list box of another web form
one help please Problem is i have two web forms  1.  ForiegnkeyTest.aspx  2. foroginkeytable.aspx   step 1 1 ForiegnkeyTest.aspx one web form <head runat="server"><script language="javascript" type="text/javascript">   function popWin()   {         var confirmWin = null;      confirmWin = window.open('foroginkeytable.aspx','anycontent',   'width=455,height=435,status');   }  </script> &...

Javascript function to show/hide div based upon dropdown list selection
I'm trying to write a JS function to show/hide div based on the dropdown list selection. But I'm unable to achieve this. I can see that when I alert (SelectedValue) I get the lstProcess Selected Index, alert(objA) returns [object], but for the visibility part it shows error "Could not find display property, Invalid Argument".  I've done this successfully in code behind by autopostback. But now I want to do this in client side. Any ideas/suggestions would be helpful function ShowHide(lever)  {  var obj = document.getElementById('_ctl0_...

How to combind two dropdown list values into one dropdown list?
Hi All, I refered some websites, they are combinding two dropdown list values into single, but i don't know .Net will support it or not? If any body knows it plz tell me how to achieve it?? EX: Go to Naukri.com and select Functional Area dropdown list there u can see main & sub category names in one dropdown list!!!   Thanks, Aswath.  hi just concatenate , or - for ex:Dropdownlist1.Datatextfield= maincategory & "," & Subcategory Regards,M.VenkatesanMy Blog : http://venkat-dotnetsamples.blogspot.comPlease remember to click “Mark as Answer” on the pos...

Web resources about - Hide dropdown list based on other dropdown list selection - asp.net.web-forms

Selection - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Megan Jones is seeking a faster cross country time to boost hopes of Olympic selection - AdelaideNow ...
SOUTH Australian Megan Jones had a simple wish on the eve of the talent-laden four-star competition at the Adelaide International Three Day Event. ...

Tinkoff Saxo's Michael Rogers aiming for Rio Olympics selection before retiring
Veteran cyclist will retire at the end of 2016, with the Tour de France and Olympics his focus.

The Law Firm Selection Guide
Download our Law Firm Selection Guide.

Gaming on Apple TV: Decent selection, hit-and-miss controls
Since the utter failure of the Apple Pippin in the mid-'90s, there's always been a certain subset of the tech world obsessed with the idea of ...

Cubs' Kris Bryant unanimous selection as NL Rookie of the Year
Chicago Tribune Cubs' Kris Bryant unanimous selection as NL Rookie of the Year Chicago Tribune Bryant, 23, set franchise rookie records with ...

Once Again, Rex Ryan Trolled The Bills' Opponents With His Selection Of Captains
The Buffalo Bills play the Dolphins today in Buffalo. The two climatologically opposite teams have a rivalry, and the Bills are coached by jolly ...

A Selection Of Best Wines For Every Thanksgiving Dish
Wines everyone will love with the "culinary madness" that is Thanksgiving...

Here are all the Official Selections for the Sploid Short Film Festival 2015
... the future. Robots fell in love, assassins from the future came back, and one minute time machines were used. Here are all the official selections ...

Jury Selection Resumes in Trial of Teen Who Killed Teacher
Jury selection resumes in trial of Massachusetts teen accused of raping, killing math teacher

Resources last updated: 11/29/2015 1:46:51 AM