Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET jQuery VB.NET
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
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
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;
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.
Varun Sareen
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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

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

  Print Answers RSS
0 OriginalGriff 335
1 Peter Leow 135
2 Zoltán Zörgő 130
3 Afzaal Ahmad Zeeshan 115
4 DamithSL 100
0 Sergey Alexandrovich Kryukov 7,442
1 OriginalGriff 5,996
2 Peter Leow 4,292
3 CHill60 2,858
4 Mika Wendelius 2,850

Advertise | Privacy | Mobile
Web01 | 2.8.150224.1 | Last Updated 23 May 2013
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