gpt4 book ai didi

asp.net - 无效的回发或回调参数。点击按钮时

转载 作者:行者123 更新时间:2023-12-04 18:16:00 24 4
gpt4 key购买 nike

我有一个带有各种控件的网页。其中两个是下拉列表。第一个dropdownlist从page_load事件的xml文件中填充。这很好。 cascadingdropdownlist扩展程序连接到第一个下拉列表,每次更改第一个下拉列表中的选择时,该扩展程序都会调用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, 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) +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扩展器而只使用常规客户端dropdownlist和一些jQuery的原因。

您有两种选择:

  • 放弃AJAX CascadingDropDown,替换为常规下拉菜单,并在使用jQuery/javascript的客户端单击上调用Web服务。
  • 在页面上禁用事件验证。 (不建议)。

  • 事件验证可防止在两次请求之间篡改页面的状态。不幸的是,无论出于何种原因,AJAX CDDL都可以做到这一点。

    这不是仅仅为了使CDDL正常工作而应该禁用的内容,因为它将影响整个页面并可能导致安全问题。

    我的建议,硬着头皮-抛弃CDDL并替换为jQuery。

    关于asp.net - 无效的回发或回调参数。点击按钮时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3393364/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com