ASP.NET Master Page: Event Validation Error

十年热恋 提交于 2019-12-25 02:29:59

问题


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: 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);
}

Thanks.


回答1:


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.



来源:https://stackoverflow.com/questions/1083198/asp-net-master-page-event-validation-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!