Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript C#4.0 , +
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() == 
     auditTableColumnsArray[i][0].toString().toLowerCase())
 {
    ddlDataType.options[j].selected = true;
    $get("<%= hfDataType.ClientID %>").value = ddlDataType.options[j].value;
    break;
 }
}
Posted 20-Sep-12 20:35pm
Edited 20-Sep-12 20:36pm
v2
Rate this: bad
good
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.
  Permalink  
Rate this: bad
good
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
  Permalink  
Comments
itskvini at 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
0 Mika Wendelius 261
1 Abhinav S 155
2 Peter Leow 140
3 Sergey Alexandrovich Kryukov 125
4 Kornfeld Eliyahu Peter 115
0 Sergey Alexandrovich Kryukov 8,613
1 OriginalGriff 6,536
2 Peter Leow 3,727
3 Zoltán Zörgő 3,456
4 Richard MacCutchan 2,442


Advertise | Privacy | Mobile
Web01 | 2.8.150123.1 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2015
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