asp.net - 为什么我得到这个异常 :Sys. WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument

标签 asp.net vb.net jscript

为什么会报错

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: 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.

启动保存命令的事件时出现此错误

  Protected Sub DataList1_ItemCommand(source As Object, e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlMainTraing.ItemCommand
        If e.CommandName = "Save" Then
            Dim lblMainId = CType(dlMainTraing.Items(e.Item.ItemIndex).FindControl("Train_M_IndxLabel"), Label)
            Dim txtSubTrainingName2 = CType(dlMainTraing.Items(e.Item.ItemIndex).FindControl("txtSubTrainingName"), TextBox)
            Dim a = addSubTraining(CInt(lblMainId.Text), txtSubTrainingName2.Text)
            ' Dim gvSubTraning As GridView = CType(e.Item.FindControl("gvSubTraning"), GridView)
            'gvSubTraning.DataBind()
        End If

    End Sub

最佳答案

在 .aspx 页面的顶部,将 EnableEventValidation 设置为 false。

enter image description here

关于asp.net - 为什么我得到这个异常 :Sys. WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9389964/

相关文章:

c# - Credentials 标志是 'true' ,但是 'Access-Control-Allow-Credentials

c# - 适配器设计模式需要什么?

c# - winform应用程序的图标绘制工具有哪些?

c# - MVC 5 自定义用户存储

c# - Xamarin 表单设置 Picker SelectedItem

sql - 从ComboBox选择中查找数据库

.net - 密码过期

regex - 大写正则表达式允许连字符名称

windows - 我可以对 JScript (.js) 或 VBScript (.vbs) 文件进行数字签名吗?

JavaScript 将字符串解析为等效对象