加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 无效的回发或回调参数.单击按钮时

发布时间:2020-12-16 07:02:37 所属栏目:asp.Net 来源:网络整理
导读:我有一个包含各种控件的网页.其中两个是下拉列表.第一个下拉列表从page_load事件的xml文件中填充.这很好用.在第一个下拉列表中附加了一个级联下拉列表扩展器,每次更改第一个下拉列表中的选择时,都会调用Web服务.这也很好.在我的两个下拉列表下面,我有一个按
我有一个包含各种控件的网页.其中两个是下拉列表.第一个下拉列表从page_load事件的xml文件中填充.这很好用.在第一个下拉列表中附加了一个级联下拉列表扩展器,每次更改第一个下拉列表中的选择时,都会调用Web服务.这也很好.在我的两个下拉列表下面,我有一个按钮,可以将页面发回.但是,当我在第二个下拉列表中进行选择并单击按钮时,我收到以下错误:

Server Error in ‘/’ Application.
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.
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,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,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) +10945696
System.Web.UI.WebControls.DropDownList.LoadPostData(String postDataKey,NameValueCollection postCollection) +72
System.Web.UI.Page.ProcessPostData(NameValueCollection postData,Boolean fBeforeLoad) +507
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) +2071

抱歉可怕的格式化.有关为什么抛出此错误以及如何防止它的任何建议?

谢谢,

解决方法

这是 AJAX CascadingDropDown扩展器的一个已知问题.

为了使其正常工作,您需要禁用事件验证.

这是一个讨论问题的主题:
http://forums.asp.net/t/1032053.aspx

我有同样的问题,这就是为什么我放弃使用CascadingDropDown扩展器,只是使用常规的客户端下拉列表和一些jQuery.

你有两个选择:

>抛弃AJAX CascadingDropDown,替换为常规下拉列表,在客户端点击jQuery / javascript调用Web服务.
>禁用页面上的事件验证. (不建议).

事件验证可防止页面状态在请求之间被篡改.不幸的是,无论出于何种原因,AJAX CDDL就是这样做的.

为了让CDDL正常工作,你不应该禁用它,因为它会影响整个页面并导致安全问题.

我的建议,咬紧牙关 – 放弃CDDL并用jQuery替换.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读