【问题标题】:Drop ASP.Net Drop Down SelectedIndex_Changed Not Working删除 ASP.Net 下拉 SelectedIndex_Changed 不工作
【发布时间】:2018-09-01 02:01:06
【问题描述】:

我为 DropDown Selected Index 更改了以下代码。但它没有按预期触发事件

<asp:DropDownList ID="DropCourseLevel" runat="server" CssClass="form-control m-input" 
AutoPostBack="true" OnSelectedIndexChanged="DropCourseLevel_SelectedIndexChanged" >
</asp:DropDownList>

我在控制台中收到以下错误

未捕获的错误:Sys.WebForms.PageRequestManagerServerErrorException: 无效的回发或回调参数。启用事件验证 在配置中使用或 在一个页面中。为了安全 目的,此功能验证回发或回调的参数 事件源自最初呈现的服务器控件 他们。如果数据有效且符合预期,请使用 ClientScriptManager.RegisterForEventValidation 方法,以便 注册回发或回调数据以进行验证。

非常感谢任何帮助

【问题讨论】:

  • 看看你的Page_Load。我猜有代码将页面和这个下拉列表数据绑定。只做if(!IsPostBack)
  • 请检查添加的附加错误信息
  • 你在stackoverflow上搜索过这个错误吗?你会找到答案的。您是否通过 javascript 更改下拉列表的内容?
  • @TimSchmelter 我能够通过在我的页面代码中添加 EnableEventValidation="false" 来解决问题。感谢您的回复

标签: c# asp.net dropdown


【解决方案1】:

我能够通过在我的 页面代码

<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" 
CodeBehind="Application.aspx.cs" Inherits="USI.User.Application" 
Title="Course Application" MasterPageFile="~/User/MyPage.Master" %>

【讨论】:

    【解决方案2】:

    尝试在您的 aspx 页面上将此属性设置为:

    EnableEventValidation="false"
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-30
    • 1970-01-01
    • 1970-01-01
    • 2015-08-09
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多