Solved

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

Posted on 2011-09-19
4
257 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
[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
  • 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

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!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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