Hi
I have 2 user controls(ascx files) that are being used inside my single aspx page that also generates a postback.
I want to restore the prior values selected when a postback occurs, so I have used hidden controls inside my ascx pages that store the selected values for an input and ddl(knockout select).
When the postback occurs I am writing viewstate to hidden controls.
When I am navigating to the previous page, I am using hidden controls to write to viewstate which then refreshes the UI automatically.
Problem:
I have been able to restore my input fields but unable to restore my drop down box(knockout select) even though I see the correct values if i use data-bind on a input control.
What I have done to resolve the issue:
I have made sure of the fact that I am writing and reading the values from hidden controls.
So when i navigate to the previous page, I see the prior selected value for my input and ddl(knocout-select) controls.
While debugging, I realized that having JUST 1 ALERT STATEMENT at the beginning inside of my document.ready() function restores my controls including ddl(Knocout-select).
As soon as I comment my alert statement, I am left with my ddl initialized to the 1st value instead.
Enter code here...
Writing to Hidden Control:
$('hiddenControl1').val(appViewModel.currentUser().name());
$('hiddenControl2').val(appViewModel.currentUser().location()); //this is the ddl.
Reading from hidden Control:
appViewModel.currentUser().name($('#hiddenControl1').val());
appViewModel.currentUser().location($('#hiddenControl2').val());
The confusing part is what would alert statement be causing the controls to be restored to prior values except the wait for the user to click on alert.
Thanks.