Saturday, March 24, 2012

populate dropdown onchange without reloading page

I have 2 dropdowns, county and district.

When the county changes, I want the district dropdown to automatically
update with a list of districts in that county, but I don't want the
page to have to reload when county changes.

I remember doing this before in classic ASP with javascript, can I do
this with a dropdownlist in ASP.NET or should I stick with the HTML
dropdown?

Thanks,
Peter
--

"I hear ma train a comin'
... hear freedom comin"It has to be done in JavaScript. Whether you use an ASP.Net dropdownlist or
the HTML <select> really doesn't matter. Just note that items added to the
dropdownlist dynamically won't exist when you do post back. You'll need to
use the good-old Request.Form.

You can check out:
http://msdn.microsoft.com/library/d...tSpicedAjax.asp

which has an AJAX implementation of creating linked dropdowns..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Stimp" <ren@.spumco.com> wrote in message
news:slrndkl22h.k78.ren@.carbon.redbrick.dcu.ie...
>I have 2 dropdowns, county and district.
> When the county changes, I want the district dropdown to automatically
> update with a list of districts in that county, but I don't want the
> page to have to reload when county changes.
> I remember doing this before in classic ASP with javascript, can I do
> this with a dropdownlist in ASP.NET or should I stick with the HTML
> dropdown?
> Thanks,
> Peter
> --
> "I hear ma train a comin'
> ... hear freedom comin"

0 comments:

Post a Comment