 |
| ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 20th, 2006, 06:30 AM
|
|
Registered User
|
|
Join Date: Apr 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Bind two dropdown without autopostback
I have two dropdownlists, the first is populated with a fixed
collection, and the second has no listitems. When the first dropdown
is selected the second one will populate accordingly. Is there a way
that I can have the list items in the second dropdown populate without
using an auto postback? Thank you
|
|

April 20th, 2006, 01:46 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Yes, you will have to use JavaScript, or AJAX.
|
|

April 21st, 2006, 12:08 AM
|
|
Registered User
|
|
Join Date: Apr 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
can u please tell me the code using javascript....
|
|

April 21st, 2006, 02:03 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
No I can't. Try posting in a JavaScript forum, the would be better to help you there.
|
|

March 28th, 2007, 04:10 AM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by xs2bharat
Hi.....this is madhu.....even i am devoloping an asp.net application where i need to populate dropdown upon selecting another dropdown without postbacks.Help me out if this is working for you....
thanks in advance
madhu
|
k.madhu
|
|

April 11th, 2007, 12:26 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2006
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I had such a scenario once. I can't give you the code it self because I don't have it :), but concept is simple;
If you are using JavaScript, you need to create an HTML Hidden field, and store the values at it and then copy it back at the second drop down list (or listbox if you where using one).
But I really recommend using AJAX, it's a good practice, and you can find some good free assemblies which can help you, me my self I really like "Anthym" it's very simple yet powerful, anyway with AJAX I don't think you'll have any problem :)
Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
|
|

April 11th, 2007, 07:41 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
|
|
Hi,
I'm just curious. I use muliple drop-downs extensively in my applications that fire on SelectedIndexChanged. They work soooo fine. I used to do those with Javascript. What a pain! Why can't you tolerate the postback?
Thanks,
Richard
|
|

April 12th, 2007, 01:44 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2006
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Well it really depends on your application, if it's published on the internet, or if the amount of data posted into the page is relatively huge, I believe you should minimize the amount of data posted from/to the server, and the amount of the server trips too.
But if it's and internal web application, that is published in an internal LAN, well.. yeah I agree, why bother :).
But anyway it's always a good practice to try new stuff, thats why we have choosen this field of studying for after all :D
Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
|
|

April 12th, 2007, 03:13 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
|
|
If you don't want to send a lot of data to the client then the javascript solution is the worst since it will send out all of the data at once to the client for all of the options in the first drop-down. In the javascript solution all of the data exists on the page and then is accessed whenever you change the selection in the first drop-down. And it can be extremely messy.
I'll send some example code if you're still interested... and I can still find some of my own since the autopostback and SelectedIndexChange have been a God send for me. However, I have never tried to integrate that javascript into a .NET application.
Richard
|
|

April 15th, 2007, 12:41 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2006
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yeah rstelma I agree with the messy part, JavaScript by nature is a very messy scripting language, but when you say:
"If you don't want to send a lot of data to the client then the JavaScript solution is the worst since it will send out all of the data at once to the client for all of the options in the first drop-down", I really disagree :), although it's true you send some extra script when using a JavaScript, but that this data is sent only when you inquire the page, after that, as you said, all the work is processed on the client machine, while if you used "autoPostBack", every time you do the even (change the index in our case) you'll do a server trip, which is an extra load on the server, specially if you are inquiring a huge amount of data from a database and sending it through the internet, it will be like hell to you customer to wait for the page :)
Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
|
|
 |