Princess
Princess

Reputation: 443

Javascript displays div is gone after postback

I have a page that has a button that displays the contents of a div with javascript. I have a ASP.net validator control that does a postback. If I step though my javascript in firebug the page still has the div visible, and if i just let the page run normally the javascript makes the div visible for a second then the postback resets the visibility to off when it reloads. How can I stop this from happening?

Thanks!

Upvotes: 1

Views: 1031

Answers (1)

Mike Perrenoud
Mike Perrenoud

Reputation: 67898

When making the DIV visible set the value of a hidden field that will be persisted in the post back. Read that value in the Load and determine if you need to make that same DIV visible server side.

When the post back occurs the entire page is rebuilt and so the things that changed client side, disconnected from the server, can't just simply be persisted.

Upvotes: 1

Related Questions