开发者

JQuery/ ASP.Net - How to Maintain the State of Hidden UI Elements across Postbacks?

I'm working on a webform with various controls. Depending on user-input I show/hide (using JQuery's show()/hide开发者_StackOverflow() functions) bits of the GUI. However if the form is posted-back and fails validation, I want the GUI to remain in the same state it was pre-postback rather than returning to the first-load state. Obviously the ASP.Net controls retain state, but I have HTML containers that are pure client-side objects.

In attempting to design a solution I find myself heading towards the murky (and tricky-to-debug) realms of hidden form fields - more reminiscent of my pre-JQuery work than anything 21st Century :-(

Can anyone suggest a better way ...?


If anyone's reading this:

I went with a JQueryish solution - a JS function now runs onready. It checks the state of any ASP.Net controls which act as 'visibility controllers' (which obv. maintain their own state across postbacks) and sets the UI accordingly via JQuery calls.


I think the trick is to use the hidden fields to persist the state of the client-side fields.

So the process is something like:

user action -> update hidden value(s) -> update UI

Then when the page posts back, you re-set the UI:

page load -> update UI

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜