I'm using a select box on a web form (in MVC), populated using Html.DropDownList. When selection within this box changes, I need to modify the form (hide / show various controls). Is it possible to trigger a Selection Changed event from Html.DropDownList,
or do I need to manually create the Select box, populate it manually and respond to the event?
daggmano
Member
28 Points
23 Posts
Html.DropDownList selection changed
Jun 19, 2008 12:30 AM|LINK
I'm using a select box on a web form (in MVC), populated using Html.DropDownList. When selection within this box changes, I need to modify the form (hide / show various controls). Is it possible to trigger a Selection Changed event from Html.DropDownList, or do I need to manually create the Select box, populate it manually and respond to the event?
MVC Events Html.DropDownList
tgmdbm
Contributor
4392 Points
883 Posts
ASPInsiders
MVP
Re: Html.DropDownList selection changed
Jun 19, 2008 02:44 AM|LINK
simply pass in an onchange handler with htmlAttributes
new { onchange = "DoSomeStuff()" }
Then just write a javascript function that does some stuff and you're good.
daggmano
Member
28 Points
23 Posts
Re: Html.DropDownList selection changed
Jun 19, 2008 04:49 AM|LINK
Once I scratched around my head for my memory of javascript, it worked a treat! Thanks.