Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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
Comments
Richard C Bishop 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.

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
 
Share this answer
 
Check have you placed a code line

C#
If (!Page.IsPostback)
    "Your Dropdown Binding Here."
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900