开发者

Added controls lost on postback

I have added html controls through javascript. However, when the page posts back, all of the added controls are lost开发者_JS百科. Is there a way to retrieve it?

Thanks, JV


They will be,if you modify the dom with javascript the modifications will not persist through a postback, whether it is static html or dynamic server side generated you will get a new page. You need to re add the controls every time.


Seems like you have a couple of options. Either

  1. Add a parameter to your POST to indicate that the fields were present, then if the server sees that that parameter is set, you write the fields out in your response; or

  2. Do the form submission by AJAX, leaving your page undisturbed.


Because the controls are dynamically added with javascript, they are supposed to vanish. If feasible, you can put them directly in your html.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜