Click here to Skip to main content
13,096,798 members (84,015 online)
Rate this:
Please Sign up or sign in to vote.

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 11:13am
richcb 15-May-13 17:22pm
You will need to post the code you are using.
jkirkerx 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2017
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