无效的回发或回调参数。使用‘<Pages enableEventVal环流=“true”/>’

无效的回发或回调参数。使用‘<Pages enableEventVal环流=“true”/>’

当我从客户端回发一个页面时,我会得到以下错误。我在客户端有修改asp:ListBox的JavaScript代码。

我们怎么解决这个问题?

错误详细信息如下:

Server Error in '/XXX' Application.


--------------------------------------------------------------------------------

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> 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 <pages enableEventValidation="true"/> 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.




慕森卡
浏览 347回答 3
3回答

胡说叔叔

在PageLoad事件中有代码吗?如果是,那么也许通过添加以下内容会有所帮助。if&nbsp;(!Page.IsPostBack){&nbsp;//do&nbsp;something&nbsp;}当您单击命令并再次运行Page_Load时,将引发此错误,在正常生命周期中,PageLoad->ClickonCommand->Page_Load(再次)->ProcessItemCommand事件

慕运维8079593

我有过使用DataGrid的经验。其中一列是“选择”按钮。当我单击任何行的“选择”按钮时,我收到了以下错误消息:“无效的回发或回调参数。在页面中使用配置或<%@Page EnableEventVal环流=”true“%>启用事件验证。出于安全考虑,此功能验证回发或回调事件的参数是否来自最初呈现它们的服务器控件。如果数据有效且预期,请使用ClientScriptManager.RegisterForEventValidation方法注册回发或回调数据以进行验证。”我修改了几个代码,最后成功了。我的经验路线:1)我将页属性更改为EnableEventValidation="false".&nbsp;但没起作用。(这不仅出于安全原因是危险的,我的事件处理程序也没有被调用:void Grid_SelectedIndexChanged(object sender, EventArgs e)2)我实施了ClientScript.RegisterForEventValidation在渲染方法中。但没起作用。protected&nbsp;override&nbsp;void&nbsp;Render(HtmlTextWriter&nbsp;writer){ &nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(DataGridItem&nbsp;item&nbsp;in&nbsp;this.Grid.Items) &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Page.ClientScript.RegisterForEventValidation(item.UniqueID); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(TableCell&nbsp;cell&nbsp;in&nbsp;(item&nbsp;as&nbsp;TableRow).Cells) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Page.ClientScript.RegisterForEventValidation(cell.UniqueID); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(System.Web.UI.Control&nbsp;control&nbsp;in&nbsp;cell.Controls) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(control&nbsp;is&nbsp;Button) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Page.ClientScript.RegisterForEventValidation(control.UniqueID); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;}}3)我将网格列中的按钮类型更改为PushButton到LinkButton.&nbsp;啊,真灵!(“ButtonType=”LinkButton“)。我认为如果您可以将按钮更改为其他控件,如”LinkButton“,在其他情况下,它会正常工作。
打开App,查看更多内容
随时随地看视频慕课网APP