zoukankan      html  css  js  c++  java
  • 回发或回调参数无效。在配置中使用 <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)
  • 相关阅读:
    [转]谁抢了我的焦点
    VBA 对比两行数据
    VBA 自动得到分数
    VBA Excel 对比两列数据
    将图片读到二进制
    [转]常用字符与ASCII代码对照表
    [转]Java 运算符的优先级
    SqlBulkCopy 快速插入数据
    多列转一行
    C# 线程小结
  • 原文地址:https://www.cnblogs.com/pipizhu/p/1595687.html
Copyright © 2011-2022 走看看