mavera
mavera

Reputation: 3241

Javascript and Postback problem

I have a button when i click it, some text from a textbox is got and written inside a p tag via javascript. I have another button that cause page postback. But after postback, contents which added by javascript are disappearing.

Is there a way to solve this problem ?

Upvotes: 1

Views: 908

Answers (3)

Nitish Katare
Nitish Katare

Reputation: 1165

You can use ajax Update panel to partial post back the page on buton click

Upvotes: 0

naruu
naruu

Reputation: 169

If you're using C# and ASP .NET, try using server-side controls and functions instead of javascript. These preserve their state during postback.

Or do you really must use javascript?

Upvotes: 0

David Mårtensson
David Mårtensson

Reputation: 7620

Either use ajax to postback part of the page excluding the part you change with javasciprt or store the changes in a formfield so that they can be remade after postback.

Clientside javascript changes are not visible to the server and will disapear efter postback since the page is renderd from start again.

Upvotes: 2

Related Questions