Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Editable DropDownList


Message #1 by "Lars Tengstedt" <Lars.Tengstedt@e...> on Thu, 22 Aug 2002 11:58:31 +0200
Hi,

Has anyone know of a way to create a DropDownList where you can type in
an option as well?
Just like the ComboBox with ComboBoxStyle set to DropDown.

Thanx.
Lars Betak Tengstedt
Denmark
Message #2 by Imar Spaanjaars <Imar@S...> on Thu, 22 Aug 2002 18:19:16 +0200
This won't work as normal browser don't allow this. Drop downs are always 
read only.

You could create an ActiveX control (yuk) or use some fancy JavaScript to 
simulate the behavior.

In JavaScript you could do something like:

1. Add an option "<Add new option>" to your list.
2. In the onchange event of the listbox, see if the "new" option was chosen.
3. If so, hide the drop down, and show a textbox instead
4. In the onblur event of the textbox, recreate the drop down (or just add 
the item, depending on your browser target)

This isn't a trivial task to do, but it's the only one I know of and 
managed to create ;-)

Regards,

Imar



At 11:58 AM 8/22/2002 +0200, you wrote:
>Hi,
>
>Has anyone know of a way to create a DropDownList where you can type in
>an option as well?
>Just like the ComboBox with ComboBoxStyle set to DropDown.
>
>Thanx.
>Lars Betak Tengstedt
>Denmark


Message #3 by "Sampath, Ramanujam (Cognizant)" <SRamanuj@c...> on Fri, 23 Aug 2002 10:35:59 +0530
Well Imar...
Adding a javascript or any other script will only prove to be fatal. because
it will not submit values to the server and hence on any other server
controls method or property call will only clear all the values and will not
be stored, i.e. when the page is refreshed the dropdownlist will not have
the items added by the script.... SO !!!!!!... should think of an another
idea...!!!! 

keep me posted....

S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
     : +xx xx xxx xxxx                 [Res]


-----Original Message-----
From: Imar Spaanjaars [mailto:Imar@S...]
Sent: Thursday, August 22, 2002 9:49 PM
To: ASP+
Subject: [aspx] Editable DropDownList


This won't work as normal browser don't allow this. Drop downs are always 
read only.

You could create an ActiveX control (yuk) or use some fancy JavaScript to 
simulate the behavior.

In JavaScript you could do something like:

1. Add an option "<Add new option>" to your list.
2. In the onchange event of the listbox, see if the "new" option was chosen.
3. If so, hide the drop down, and show a textbox instead
4. In the onblur event of the textbox, recreate the drop down (or just add 
the item, depending on your browser target)

This isn't a trivial task to do, but it's the only one I know of and 
managed to create ;-)

Regards,

Imar



At 11:58 AM 8/22/2002 +0200, you wrote:
>Hi,
>
>Has anyone know of a way to create a DropDownList where you can type in
>an option as well?
>Just like the ComboBox with ComboBoxStyle set to DropDown.
>
>Thanx.
>Lars Betak Tengstedt
>Denmark



---

ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442

ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450

These books are a complete reference to the ASP.NET namespaces 
for developers who are already familiar with using ASP.NET. 
There is no trivial introductory material or useless .NET 
hype and the presentation of the namespaces, in an easy-to use 
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes, 
giving you those real-world tips that the documentation doesn't 
offer, and demonstrating complex techniques with simple 
examples.  

---

Message #4 by Imar Spaanjaars <Imar@S...> on Fri, 23 Aug 2002 08:02:44 +0200
Well, it all depends how you implement this stuff.

Suppose you have a drop down called lstStuff. Now, simply create a hidden 
textbox called txtStuff. In the submit / validation routine of the form 
simply copy the selected index or value to the hidden txtStuff and it gets 
submitted to the server. Server-side you could rebuild the drop down based 
on the submitted text.

Like I said in my previous e-mail: it isn't a trivial task to do ;-)

Imar


At 10:35 AM 8/23/2002 +0530, you wrote:
>Well Imar...
>Adding a javascript or any other script will only prove to be fatal. because
>it will not submit values to the server and hence on any other server
>controls method or property call will only clear all the values and will not
>be stored, i.e. when the page is refreshed the dropdownlist will not have
>the items added by the script.... SO !!!!!!... should think of an another
>idea...!!!!
>
>keep me posted....
>
>S.Ramanujam
>Programmer Analyst
>38 & 39 Whites Road,
>WCB - Whites Road Circular Building
>Royapettah, Chennai - 600014
>Ph : +xx xx xxx xxxx Extn 5113 [Off]
>      : +xx xx xxx xxxx                 [Res]


Message #5 by "Imar Spaanjaars" <Imar@S...> on Sat, 31 Aug 2002 17:17:49
In case you still don't believe it's possible, I ran into an ASPX control 
the other day that does exactly what you want. It emulates a true 
combobox and is able to submit NEW values to the server as well

Check it out at:

http://www.metabuilders.com/Tools/ComboBox.aspx


Imar


> Well, it all depends how you implement this stuff.

Suppose you have a drop down called lstStuff. Now, simply create a hidden 
textbox called txtStuff. In the submit / validation routine of the form 
simply copy the selected index or value to the hidden txtStuff and it 
gets 
submitted to the server. Server-side you could rebuild the drop down 
based 
on the submitted text.

Like I said in my previous e-mail: it isn't a trivial task to do ;-)

Imar


At 10:35 AM 8/23/2002 +0530, you wrote:
>Well Imar...
>Adding a javascript or any other script will only prove to be fatal. 
because
>it will not submit values to the server and hence on any other server
>controls method or property call will only clear all the values and will 
not
>be stored, i.e. when the page is refreshed the dropdownlist will not have
>the items added by the script.... SO !!!!!!... should think of an another
>idea...!!!!
>
>keep me posted....
>
>S.Ramanujam
>Programmer Analyst
>38 & 39 Whites Road,
>WCB - Whites Road Circular Building
>Royapettah, Chennai - 600014
>Ph : +xx xx xxx xxxx Extn 5113 [Off]
>      : +xx xx xxx xxxx                 [Res]


  Return to Index