我有一个稳定的错误,每次我按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)。
编辑:上!!!