dropdownlist is asp.net
I 开发者_开发问答want to display countries and the corresponding states in dropdownlist
. Which method is efficient for storing the data in database and displaying it using updatepanel
or filling dropdown
at client side using javascript. I am confused which approach should I follow or is there any other way?
If you need to populate the list when the page is loaded you should use standard binding methods at the server side. If you need to populate the list when an action is performed later on the page you could use an UpdatePanel which will perform an ajax callback to the server. And finally the best option IMHO would be to have a server side action with caching enabled returning a JSON encoded representation of the countries which would be invoked using ajax and bound to a normal <select>
without using any server side asp:DropDown...
Dear Confused, updatepanel
will be better approach as you will not have to reload the whole page. But as user may go through the countries using up-down keys it will be easier if you trigger update of panel after user leaves countries dropdownlist.
PS:- Updatepanel
is also client side approach. If you feel comfortable with jQuery then you can use jQuery ajax to upload states list.
精彩评论