无效的Viewstate问题 [英] Invalid Viewstate issue

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

问题描述



我正在使用C#开发ASP.NET应用程序.
我将Page1.aspx作为父页面.当我单击Page1.aspx上的按钮时,将打开另一个页面Page2.aspx作为子窗口.
我将gridview的选定行从第2页传递到第1页.我也通过Reques.querystring从另一个页面获取page1中的一些值.

但我得到了例外:
无效的ViewStste或ViewState可能已损坏.

Hi,

I am developing ASP.NET application with C#.
I am having Page1.aspx as a parent Page. When i click a button on Page1.aspx, another page Page2.aspx as a child window opens.
I am passing selected rows of gridview from page2 to page1. Also I m getting some values in page1 from another page through Reques.querystring.

But I am getting the exception:
Invalid ViewStste Or ViewState might be corrupted.
How to fix this error?

推荐答案

通常,出现此问题的原因是,位于顶部的page元素或页面指令的EnableViewStateMac 属性设置为true默认情况下.

如果这样做没有帮助,请:
Viewstate是页面控件的值,存储在隐藏字段中,
发送回服务器.在正确处理从第2页和第3页向第1页传递值的方式之前,不太可能出现客户端错误.

查看以下链接以确保环境良好:
http://support.microsoft.com/kb/829743 [ http://bytes.com/topic/asp-net/answer/286631-viewstate-invalid-page-might损坏的问题 [
Generally, This problem occurs because the EnableViewStateMac attribute of the page element or page directive at the top is set to true by default.

If this doesn''t help then:
Viewstate are values of page controls, stored in a hidden field,
that is sent back to the server. It is unlikely a client error until your way of passing values from page 2 and Page3 to page1 are not handled properly.

Look at the following links to make sure environment is fine:
http://support.microsoft.com/kb/829743[^]
http://bytes.com/topic/asp-net/answers/286631-viewstate-invalid-page-might-corrupted-problem[^]


如果您使用的是数据绑定控件,例如GridView/FormsView/DetailsView.当这些控件中的任何一个处于页面的编辑模式时.一旦控件处于编辑模式.应该将其更改为只读模式.将显示其他明智的无效视图状态错误消息.
由于数据绑定控件的模式更改,我在项目中遇到了此类问题.

删除了不合适的PRE标签.
If you are using Databound controls such as GridView/FormsView/DetailsView. When any of these controls is in edit mode in your page. Once the control is in edit mode. It should be changed to readonly mode. other wise invalid view state error message will be displayed.
I have encountered such issues in my project due to mode change of data bound controls.

removed inappropriate PRE tags.


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

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