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.
这个错误怎么解决??
这个错误怎么解决??
//—-通过web.config
<system.web>
<pages enableEventValidation="false"/>
</system.web>
//—-针对某个page
<%@ Page EnableEventValidation="false" … %> 2.Register For Event Validation
其原理就是让asp.net记录这个postback value.
RegisterForEventValidation必须在render时调用.protected override void Render(HtmlTextWriter writer)
{
ClientScript.RegisterForEventValidation(_recipeList.UniqueID,"4");
base.Render(writer);
}如果我们自己写了一个control,需要使用validate events功能,就需要使用SupportsEventValidation attribute,[SupportsEventValidation]
public class DynamicDropDownList : DropDownList
{
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
Page.ClientScript.RegisterForEventValidation(this.UniqueID, "4");
base.Render(writer);
}
}目前,asp.net还不能单独禁止某个control的validate events功能.
可以参考这个
http://odetocode.com/Blogs/scott/archive/2006/03/20/3145.aspx
http://odetocode.com/Blogs/scott/archive/2006/03/21/3153.aspx