我有一个稳定的错误,每次点击 F5 时都会重现:
有2个网格(主 - 详细信息),并且当主网格上发生聚焦行更改事件时,我的客户端代码引发了回调错误。像这样:
this.mainGrid.ClientSideEvents.FocusedRowChanged = string.Format(@"
function(s, e)
{{
if (typeof({0}) != 'undefined')
{0}.PerformCallback(s.GetFocusedRowIndex());
}}",
this.detailsGrid.ClientInstanceName);
该错误仅在 mozilla firefox 中重现! (是的, IE 没有问题,这有点奇怪=))
非常重要的是:该错误仅在启用事件验证时重现,即:
... EnableEventValidation="false" %> // no error in this case
我建议原因是在必要的字段加载之前触发了回调(因为我得到它,事件验证使用了一些隐藏的字段),所以我使用setTimeout
检查了它:
this.mainGrid.ClientSideEvents.FocusedRowChanged = string.Format(@"
function(s, e)
{{
window.setTimeout(function () {{
if (typeof({0}) != 'undefined') {0}.PerformCallback(s.GetFocusedRowIndex());
}}, 2000);
}}",
this.detailsGrid.ClientInstanceName);
但是,tat并没有帮助。 2秒后,回叫开始,我收到错误。
它仅在刷新时发生 - 第一次加载页面时不会引发错误。
禁用网格的行缓存也没有帮助。
需要帮助! =))
编辑:这是StackTrace
at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError)
at System.Web.UI.ClientScriptManager.EnsureEventValidationFieldLoaded()
at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument)
at System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument)
at System.Web.UI.WebControls.HiddenField.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.WebControls.HiddenField.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.solutions_cashcenter_stockmanagement_frames_takeintostorageordersviewframe_aspx.ProcessRequest(HttpContext context) in c:\Users\udod\AppData\Local\Temp\Temporary ASP.NET Files\website\b07be668\e534e3ef\App_Web_jeqyhxze.10.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Edit2:' EnsureEventValidationFieldLoaded ' - 是的,我看到了这一点,但是......如果我等了2秒,它怎么能不加载?
Edit3:您可能会注意到这不是 IIS 问题(屏幕截图为127.0.0.1 ip)。
编辑:UP !!!
答案 0 :(得分:6)
昨天我遇到了同样的错误,发现了类似的问题:http://sietch.net/ViewNewsItem.aspx?NewsItemID=185
我目前的解决方法是:
$(document).ready(function(){
$('#__EVENTVALIDATION').attr('autocomplete', 'off');
});
它似乎有效。但是我还在测试。