Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET jQuery VB.NET
Hello,
 
I have a drop-down list in a user control, AutoPost back is set to false, dropdown list's onchange event I cal a javascript function to read the selected text and assign it to some other text box in the user control. "EnableViewState' is set to true.
 
BUT when there is a postback I dont get the selected value from the dropdown list. What I am I missing? What should I do to retain the selected value in the dropdown list?
 
I am using Jquery for client side scripting
Posted 15-May-13 12:13pm
Nikky26169
Comments
richcb at 15-May-13 17:22pm
   
You will need to post the code you are using.
jkirkerx at 15-May-13 18:53pm
   
Do you get the original selected value after postback?
 
Would have to see the call in javascript or jquery,
 
and the server side code for picking up the value
 
If you don't use the onchange event, the value posts?
Mohit_Rudra at 16-May-13 1:55am
   
You will need to post the code you are using.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Dear Friend,
 
Before postback or on the selection of value from the dropdownlist; store the selected value from the drop down list in Session variable or nin ViewState variable.
 
Then Whenever there is post back;
window_onload()
is called. In the same event of the page you need to fill your dropdownlist with the values and after the same values have been populated into the dropdownlist, then with the help of JQUERY you can set the selected value for the dropdownlist from the state variable in which you have earlier stored the value before postback.
 
**I don't know when you are filling the dropdwonlist; So i have suggested you a solution which you can apply or you can continue with your own method and appending my solution of keeping the selected value in the state variable with your own solution.
 
Please don't forget to mark this as your answer if it helps you out.
 
Regards
 
Varun Sareen
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Check have you placed a code line
 
    If (!Page.IsPostback)
        "Your Dropdown Binding Here."
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 85
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2014
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