Click here to Skip to main content
13,352,157 members (77,632 online)
Rate this:
Please Sign up or sign in to vote.
I am setting selected item of one drop down according to the value of other drop down through javascript.
But I am not getting this selected item value in code behind.
Finally I used Hidden Field for setting the drop down value and then used this hidden field value in code behind.

Can any one explain me this behavior?

java-script code : -

for (var j = 0; j < ddlDataType.options.length; j++) 
 if(ddlDataType.options[j].text.toLowerCase() == 
    ddlDataType.options[j].selected = true;
    $get("<%= hfDataType.ClientID %>").value = ddlDataType.options[j].value;
Posted 20-Sep-12 20:35pm
Updated 20-Sep-12 20:36pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Have you enabled view state of the dropdown?
if not set "EnableViewState=true" for the control.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I think u have ur fill drop down method in page load, instead of !ispostback, check it once
itskvini 22-Sep-12 1:04am
Well !IsPostBack, that has been a practice for a while now. So no luck there.
Actually it could not have been an issue if the setting of drop down would have been done on code behind. But we didn't want unnecessary postback. That's why doing it using javascript.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180111.1 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100