开发者

Javascript and Postback problem

开发者 https://www.devze.com 2023-01-22 02:05 出处:网络
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 ca开发者_运维问答use page postback. But after postback, contents

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 ca开发者_运维问答use page postback. But after postback, contents which added by javascript are disappearing.

Is there a way to solve this problem ?


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.


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?


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

0

精彩评论

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