Invalid postback or callback argument.
Event validation is enabled usingin 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.
当我将EnableEventValidation =“false”设置为web表单页面时就像打击一样.它会引发事件;
<%@ Page EnableEventValidation="false" %>
但我认为设置那个假不应该是个好主意.那么,这里的替代方案是什么?有错误说“使用ClientScriptManager.RegisterForEventValidation方法来注册回发或回调数据以进行验证.”但是我要在哪里注册那件事?谢谢 !
另外,我在usercontrol中使用了一些AjaxControlToolkit控件和一些jquery的东西.
解决方法
基本上,您需要使用事件验证引擎注册用户控件的子控件.
C# protected override void Render(HtmlTextWriter writer) { // Register controls for event validation foreach (Control c in this.Controls) { this.Page.ClientScript.RegisterForEventValidation( c.UniqueID.ToString() ); } base.Render(writer); } VB Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter) For Each aControl As Control In Me.Controls Me.Page.ClientScript.RegisterForEventValidation(aControl.UniqueID.ToString) Next aControl MyBase.Render(writer) End Sub
现在这可能无法解决您的问题,因为我不确定您是如何返回字符串的.另一个article解释说,事件验证是控件的唯一ID和它可以传回的所有值的组合.如果您使用按钮的命令值来传递文本,则可能无法执行此任务.