Viewstate和JavaScript [英] Viewstate and javascript

查看:155
本文介绍了Viewstate和JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有1个aspx页面,它也是一个包含动态字段的数据网格.此页面称为模型表单.现在当我单击此模型表单的关闭事件时,我想回到父aspx页面.现在发生的是我只看到静态字段,看不到动态字段.

那我该怎么办.

请帮帮我.

提前致谢.

Hi All,

I have 1 aspx page which as a datagrid containing dyanmic fields also.This page calls a model form.Now when i click on close event of this model form I want to get back to the parent aspx page.What''s happening now is i get only static fields and dynamic fields are not seen.

so what should i do .

Please help me.

Thanks in Advance.

推荐答案

正如您所发现的,添加到客户端DOM上的控件不会保存在ViewState中并在后面的代码中重构. ViewState进行了加密和验证以防止篡改,因此无法添加动态控件.

一种常见的方法是使用JavaScript和Ajax将控件的值发送到服务器.这可以通过Web服务或带有ASP.NET的PageMethods来完成.
As you have found out controls that are added to the DOM on the client do not get saved in ViewState and reconstituted in the code behind. ViewState is encrypted and validated to prevent tampering so there is no way to have the dynamic controls added.

A common method is to use JavaScript and Ajax to send the values of the controls to the server. This can be done using a web service or using PageMethods with ASP.NET.


关闭模式窗体时是否发生任何回发.如果是!那么您需要再次重新创建动态控件!有时我也遇到过类似的问题,这就是解决方案.
希望这会有所帮助!
Is there any postback happening when you close the modal form. If yes! then you need to recreate the dynamic controls again! I also faced similar issue sometime back and this was the solution.
Hope this helps!


关闭viewstate是没有用的,这意味着如果您不保留回发状态.使用ajax并在每次回发上绑定控件.因此屏幕不会闪烁,也不会根据需要获得输出.

避免使用updatepanel,请使用pagemethod或Webservice这样做.

这只是一个主意.....可能会有所帮助
Turnoff the viewstate is it is of no use, means if you are not retaining the state on postback. Use ajax and bind the control on every postback. So the screen will not flicker, as well as get the output as you want.

Avoid the use of updatepanel, use pagemethod or webservice to do so.

it is just an idea..... may be it helps


这篇关于Viewstate和JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆