ASP.NET母版页:事件验证错误 [英] ASP.NET Master Page: Event Validation Error

查看:119
本文介绍了ASP.NET母版页:事件验证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在母版页中添加了一个中继器. 中继器具有一个用于设置其CommandArgument的按钮.

I included a repeater in my master page. The repeater has a button that I set its CommandArgument.

但是,当我单击按钮时,出现以下异常:

However when I click the button I get the following exception:

System.ArgumentException:无效的回发或回调参数.使用in配置或页面中的<%@页面EnableEventValidation ="true"%>启用事件验证.为了安全起见,此功能验证回发或回调事件的参数源自最初呈现它们的服务器控件.如果数据有效且预期,请使用ClientScriptManager.RegisterForEventValidation方法来注册回发或回调数据以进行验证.

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.

并且不会继续到事件处理程序.

And it doesn't continue to the event handler.

注意: 我尝试将这些行添加到母版页,但无济于事:

Note: I tried adding these lines to the master page but it doesn't help:

protected override void Render(HtmlTextWriter writer)
{
    Page.ClientScript.RegisterForEventValidation(rptrLanguages.ClientID);
    base.Render(writer);
}

谢谢.

推荐答案

您是否正在该页面上进行任何数据绑定?如果是这样,它是否在检查!IsPostBack之间发生?

Are you doing any databinding on that page? If so, is it happening between a check for !IsPostBack ?

if (!IsPostBack) { // do databinding }

提到了类似的问题 此处 .

A similar issue was mentioned here.

这篇关于ASP.NET母版页:事件验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆