|
-
Sep 19th, 2008, 07:54 AM
#1
Thread Starter
Fanatic Member
DropDownList - limit number of lines shown
Is it possible to limit number of lines being shown in the drop down list? Example, If I have 200 lines being filled I only want 10 lines to show and then use scrolldown to view the entire list. Thank you.
-
Sep 19th, 2008, 11:24 AM
#2
Re: DropDownList - limit number of lines shown
The DropDownList asp.net control generates a <select> html element which has a size attribute which indicates the number of visible elements.
You can add the attribute to the DropDownList control.
<asp ropDownList ID="DropDownList1" runat="server" Size="10" >
Visual Studio will indicate that Size is not an attribute of the DropDownList but this is just informational, the attribute gets written in the final html. eg
<select name="DropDownList1" id="DropDownList1" Size="10">
You could also add the Size attribute at runtime.
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DropDownList1.Attributes.Add("Size", "10")
End Sub
Last edited by brucevde; Sep 19th, 2008 at 11:31 AM.
-
Sep 19th, 2008, 12:09 PM
#3
Thread Starter
Fanatic Member
Re: DropDownList - limit number of lines shown
Hi brucevde,
That seems to do the trick. I need to set the size at the time when user clicks the down arrow and then display the number of lines I want. I tried to find the event for this, is there any? Thank you for your help.
Last edited by snufse; Sep 19th, 2008 at 02:53 PM.
-
Sep 22nd, 2008, 07:30 AM
#4
Re: DropDownList - limit number of lines shown
Why do you need to do it when the select element is clicked? Do you want to change the size dynamically at runtime?
Also, the size property will make it a 'listbox' rather than limit the number of visible items in the dropdownlist. Is that what you want?
-
Sep 22nd, 2008, 07:30 AM
#5
Re: DropDownList - limit number of lines shown
To do it using javascript
Code:
<select onclick="this.size=4;">
<option>sdf</option>
<option>sdf</option>
<option>sdf</option>
<option>sdf</option>
<option>sdf</option>
<option>sdf</option>
<option>sdf</option>
<option>sdf</option>
<option>sdf</option>
<option>sdf</option>
</select>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|