I’m working on a webforms app. Currently, the user picks a category from a dropdownlist and that filters the options in the next dropdown list (cascading dropdowns). After selecting the category, a postback occurs. It’s ugly, the screen flashes, and, IMO, really unnecessary.
So, I started to dig into jQuery. At the moment, I have an alert popup when the selection changes. Yay me!
The categories and documents (displayed in the second dropdown) are currently in an objectdatasource used throughout the application. Can jQuery use the existing datasource?
Currently, we have an event handler wired up to the SelectedIndexChanged event of the category dropdown. Can jQuery use that event handler. I’m thinking jQuery could somehow use .change() and call the methods inside the event handler.
No, jQuery can’t use that handler. You can do what you need via jQuery.ajax and either defining a
Page Methodor aWeb Method(on a Web service) that performs the filtering based on the selection and returns to you some JSON data, for example.Very good example here.