i have one asp.net page(vb.net). i have two dropdownlist state and district. i filled district from state using Jquery.
Now the problem is when i submit page it throws an exception..
how can i solve this?
i have two dropdownlist state and district. i filled district from state using Jquery.
Use dropdownlist (servercontrol) only for state
and use <select> (htmlcontrol) for district and save its value during onchange event in a HiddenField (servercontrol).
You are facing Error because, asp.net not allows html injected from clientside(browser).
thank you so much for your valuable reply. but i want to do reverse process too. like if i fetch data from database then
i need to set dropdown value. how will it be possible from code behind to set html control value.?
your fix, is in PreInit you need to add the postback value to drop down list, so that it can be set during the apply postback data event. this is the same approach you use if you turn viewstate off (a really good practice).
your other option is write you own custom control that implements <select> that does not have this limitation.