Solved

Any way to get dropdownlist's list to drop down?

Posted on 2011-09-19
4
255 Views
Last Modified: 2012-08-13
Is there any way to get a dropdownlist control to display its list automatically when a page is loaded?  To "unfurl", so to speak?
0
Comment
Question by:Alastair_White
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
geowrian earned 500 total points
ID: 36564673
A normal drop down list? No. The controls are built into the client's browser, and no method exists to make them "drop down".

As an alternative, if you built your own pseudo-drop down list using divs and unordered lists and CSS, you could hide/show that div. But it's not a simple procedure and not native to ASP.NET.
0
 
LVL 16

Expert Comment

by:disrupt
ID: 36564832
Check this thread:

http://stackoverflow.com/questions/2048213/open-select-using-javascript-jquery

you can change the size which will list everything:

   





<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#<%= DropDownList1.ClientID %>").attr('size', 5);
    });
  </script>
 
<asp:DropDownList ID="DropDownList1" runat="server">
         <asp:ListItem>Item 1</asp:ListItem>
         <asp:ListItem>Item 2</asp:ListItem>
         <asp:ListItem>Item 3</asp:ListItem>
         <asp:ListItem>Item 4</asp:ListItem> 
         <asp:ListItem>Item 5</asp:ListItem> 
    </asp:DropDownList>

Open in new window

0
 
LVL 12

Expert Comment

by:geowrian
ID: 36564987
@disrupt
That's a smart idea for some options, but it's not really simulating a click of a drop down list. It's basically treating the drop down list as a multiline <select> object, which means it loses the visual drop-down aspects when the size attribute is > 1. If the list contains lots of items, it will show all of them at once (unlike a drop down list), it takes up multiple display lines (i.e. putting it in a table with many options would make all other cells push downward), etc. You can fight some of these using a number of javascript functions and some CSS (i.e. upon click convert it back to a drop-down list, use absolute positioning and z-indexes, etc.) as noted in the URL you referenced. However, it's not pretty and may not look or function as expected across browsers and/or versions (especially IE 6/7/8).

I just wanted to point out that detail - it's visually not the same as a drop down list so I wanted the OP to be aware of that.
0
 

Author Closing Comment

by:Alastair_White
ID: 36567731
Alright, that's what I wanted to know.  I am new to asp.net and even new to HTML, and I have no clue about javascript or CSS or anything.  Total noob, trying to go the easiest route.  I will work around this.  Thanks for the info.
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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

790 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