updatepanel 的事件验证问题“无效的回发或回调参数”
我是 UpdatePanel 新手,但遇到了问题。
我有 2 个下拉列表。我基本上试图根据我在第一个下拉列表中选择的内容来更新第二个下拉列表的内容。在 Chrome 中这一切都工作正常。在 IE 中,第一次更改下拉框选择时,它似乎没有执行任何操作,第二次执行此操作时,它会给出以下错误。
我读到我需要注册控件以进行验证。所以我尝试了以下方法。
protected override void Render(HtmlTextWriter writer)
{
Page.ClientScript.RegisterForEventValidation(DropDown1.UniqueID, "1");
Page.ClientScript.RegisterForEventValidation(Dropdown2.UniqueID, "2");
base.Render(writer);
}
我的两个下拉框位于用户控件内,因此我将渲染代码放置在用户控件级别,但它似乎没有帮助。我在这里缺少一些关键的东西吗?
“/”应用程序中的服务器错误。
无效的回发或回调参数。 使用启用事件验证 在配置中或<%@页面 EnableEventValidation="true" %>在一个 页。出于安全目的,这 功能验证参数 回发或回调事件发生 从服务器控制 最初渲染它们。如果数据 是有效且预期的,使用 ClientScriptManager.RegisterForEventValidation 方法以注册 回发或回调数据 验证。描述:未处理 期间发生异常 执行当前的网络请求。 请查看堆栈跟踪以了解更多信息 有关错误及其位置的信息 它起源于代码。
异常详细信息:
System.ArgumentException:无效 回发或回调参数。事件 使用 in 启用验证 配置或<%@页面 EnableEventValidation="true" %>在一个 页。出于安全目的,这 功能验证参数 回发或回调事件发生 从服务器控制 最初渲染它们。如果数据 是有效且预期的,使用 ClientScriptManager.RegisterForEventValidation 方法以注册 回发或回调数据 验证。
来源错误:
生成了未处理的异常 当前执行期间 网络请求。有关信息 异常的起源和地点 可以使用异常来识别 下面的堆栈跟踪。
堆栈跟踪:
[ArgumentException:无效回发 或回调参数。事件 使用 in 启用验证 配置或<%@页面 EnableEventValidation="true" %>在一个 页。出于安全目的,这 功能验证参数 回发或回调事件发生 从服务器控制 最初渲染它们。如果数据 是有效且预期的,使用 ClientScriptManager.RegisterForEventValidation 方法以注册 回发或回调数据 验证。]
System.Web.UI.ClientScriptManager.ValidateEvent(字符串 uniqueId,字符串参数)+8656758
System.Web.UI.Control.ValidateEvent(字符串 唯一ID,字符串事件参数)+113
System.Web.UI.WebControls.DropDownList.LoadPostData(字符串 postDataKey、NameValueCollection 收藏后)+55
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.LoadPostData(字符串 postDataKey、NameValueCollection 收藏后) +13
System.Web.UI.Page.ProcessPostData(NameValueCollection postData,布尔值 fBeforeLoad) +327
System.Web.UI.Page.ProcessRequestMain(布尔值 includeStagesBeforeAsyncPoint,布尔值 includeStagesAfterAsyncPoint)+878
I am an UpdatePanel virgin and I'm having problems.
I have 2 drop down lists. I am basically trying to update the contents of the second drop down depending on what I select on the first drop down. In chrome this all works fine. In IE it doesn't seem to do anything the first time I change the drop down box selection and once I do it a second time it gives the error below.
I have read that I need to register the control for validation. So i tried the following.
protected override void Render(HtmlTextWriter writer)
{
Page.ClientScript.RegisterForEventValidation(DropDown1.UniqueID, "1");
Page.ClientScript.RegisterForEventValidation(Dropdown2.UniqueID, "2");
base.Render(writer);
}
My two drop down boxes are within a user control so the Render code I have placed at the user control level but it doesn't seem to help. Is there some key thing I'm missing here?
Server Error in '/' Application.
Invalid postback or callback argument.
Event validation is enabled usingin configuration or <%@ Page
EnableEventValidation="true" %> in a
page. For security purposes, this
feature verifies that arguments to
postback or callback events originate
from the server control that
originally rendered them. If the data
is valid and expected, use the
ClientScriptManager.RegisterForEventValidation
method in order to register the
postback or callback data for
validation. Description: An unhandled
exception occurred during the
execution of the current web request.
Please review the stack trace for more
information about the error and where
it originated in the code.
Exception Details:
System.ArgumentException: Invalid
postback or callback argument. Event
validation is enabled using in
configuration or <%@ Page
EnableEventValidation="true" %> in a
page. For security purposes, this
feature verifies that arguments to
postback or callback events originate
from the server control that
originally rendered them. If the data
is valid and expected, use the
ClientScriptManager.RegisterForEventValidation
method in order to register the
postback or callback data for
validation.
Source Error:
An unhandled exception was generated
during the execution of the current
web request. Information regarding the
origin and location of the exception
can be identified using the exception
stack trace below.
Stack Trace:
[ArgumentException: Invalid postback
or callback argument. Event
validation is enabled using in
configuration or <%@ Page
EnableEventValidation="true" %> in a
page. For security purposes, this
feature verifies that arguments to
postback or callback events originate
from the server control that
originally rendered them. If the data
is valid and expected, use the
ClientScriptManager.RegisterForEventValidation
method in order to register the
postback or callback data for
validation.]
System.Web.UI.ClientScriptManager.ValidateEvent(String
uniqueId, String argument) +8656758
System.Web.UI.Control.ValidateEvent(String
uniqueID, String eventArgument) +113
System.Web.UI.WebControls.DropDownList.LoadPostData(String
postDataKey, NameValueCollection
postCollection) +55
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.LoadPostData(String
postDataKey, NameValueCollection
postCollection) +13
System.Web.UI.Page.ProcessPostData(NameValueCollection
postData, Boolean fBeforeLoad) +327
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint) +878
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论