删除ASP.Net下拉SelectedIndex_Changed不起作用

时间:2018-03-22 15:00:38

标签: c# asp.net dropdown

我有DropDown Selected Index Changed的以下代码。但它没有像预期的那样解雇事件

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

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

  

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

非常感谢任何帮助

2 个答案:

答案 0 :(得分:2)

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

EnableEventValidation="false"

答案 1 :(得分:0)

我可以通过添加EnableEventValidation="false"来解决问题 页面代码

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