• 回发或回调参数无效。在配置中使用 <pages enableEventValidation="true"/>


    可能出现的问题:
    回发或回调参数无效。在配置中使用 <pages enableEventValidation="true"/> 或在页面中使用 <%@ Page EnableEventValidation="true" %> 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。
    英文描述
    id 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 valida

    可行的解决方法有:

    1、在页面的<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 中添加 EnableEventValidation="false" 就可以了。(首先考虑的)

    2、通过web.config
    <system.web>
    <pages enableEventValidation="false"/>

    3、是Form嵌套,一个页面只能有一个Form,仔细检查代码就可以解决。

    4、如果页面含有 DropDownList 或 ListBox这样的控件,可能以下原因造成:

    4.1 在下拉菜单中使用ajax,常见于省市联动菜单,可能是由于在aspx页面赋给了下拉菜单初始Item值,在事件回发时提示该错误,将下拉菜单初始Item值删除,在绑定事件中添加Item项。
    4.2 原因是 DropDownList 控件的ListItem 的Value 属性 包含汉字.只要将Value 改为英文或数字的就行了.最好在web.config中添加如下语句:
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="zh-CN" uiCulture="zh-CN"/>因为 POSTBACK 如果不采用 UTF-8 编码, JAVASCRIPT 会认为有问题。
    只改 requestEncoding="utf-8" 就可以了,responseEncoding="utf-8" 不用

    5.Register For Event Validation
    其原理就是让asp.net记录这个postback value.
    RegisterForEventValidation必须在render时调用.

    protected override void Render(HtmlTextWriter writer)
  • 相关阅读:
    Java使用jxl修改现有Excel文件内容,并验证其是否对公式的结果产生影响
    Java使用MyBatis的ScriptRunner执行SQL脚本
    Linux下批量解压.Z格式文件
    Java中将一个反斜杠转换成两个反斜杠
    mysql线上操作常用命令
    MySQL主从不一致修复
    slave_exec_mode参数对主从复制的影响
    ssh访问跳过RSA key"yes/no"验证
    k8s更新Pod镜像
    Go 延迟函数 defer 详解
  • 原文地址:https://www.cnblogs.com/pipizhu/p/1595687.html
Copyright © 2020-2023  润新知