操作DOM当ASP.NET的ViewState验证 [英] ASP.NET ViewState validation when manipulating DOM

查看:194
本文介绍了操作DOM当ASP.NET的ViewState验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery和ASP.NET来显示包含按钮的对话框。一些冲刷后,我得到了在对话框中的按钮加入一点点更多的JavaScript到对话框的形式附加到工作。

I'm, using jQuery and ASP.NET to show a dialog containing buttons. After some scouring, I got the buttons in the dialog to work by adding a tad more JavaScript to append the dialog to the form.

var dlg = $('#ctl00_ctl00_PageContent_PageContent__pnlPopup').dialog({
                    autoOpen: false,
                    height: 180,
                    width: 500,
                    modal: true,
                    draggable: true
                });
         dlg.parent().appendTo($('form:first')); // without this, controls in the dialog are non-functional

直到我打开对话框这工作得很好,关闭它,然后尝试使用像父页面上ComboBox或LinkBut​​ton的控制。在这一点上,我收到了ViewState的验证错误:

This works fine until I open the dialog, close it, then try to use a control like a ComboBox or LinkButton on the parent page. At which point I get a ViewState validation error:

无法加载视图状态。控件树成视图状态
  正在装载必须被用来保存控件树匹配
  在previous请求过程中的视图状态。例如,当加入
  控件动态,一个后回过程中添加的控件必须匹配
  类型和控制的位置,在最初加入
  请求。

Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

有没有解决这个办法吗?我半明白为什么它的发生 - jQuery是改变文档的结构,但我不完全知道如何/为什么这是影响的ViewState

Is there any way around this? I half see why it's happening - jQuery is changing the structure of the documents but I'm not entirely sure how/why this is affecting the ViewState.

推荐答案

你是说你的页面所做的唯一的变化是增加在你的问题中code?你当对话框出现使服务器的任何电话?

Are you saying the only change you made to the page was adding the code in your question? Are you making any calls to the server when the the dialog comes up?

操控DOM在客户端上应该不会影响服务器的正常恢复的ViewState(能够提供你没有删除或损坏的必需元素,如窗体标签和保持连接codeD的ViewState隐藏字段)。

Manipulating the DOM on the client should not affect the server's ability to correctly restore ViewState (provided you haven't deleted or corrupted the required elements, such as the form tag and the hidden fields that hold the encoded ViewState).

你吃过看看那个失败的,也许具有Web代理,如提琴手原始的HTTP请求?

Have you had a look at the raw HTTP request that's failing, perhaps with a web proxy such as Fiddler?

这篇关于操作DOM当ASP.NET的ViewState验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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