c# - 错误 : DropdownList server error

标签 c# asp.net

我有这个下拉列表:

<asp:DropDownList runat="server" ID="CatsList" AutoPostBack="True" AppendDataBoundItems="True" DataSourceID="CatsDataSource" DataTextField="CatName" DataValueField="CatId" ClientIDMode="Static" OnSelectedIndexChanged="CatsList_SelectedIndexChanged" OnDataBound="CatsList_DataBound">
    <asp:ListItem Value="1">* SELECT CATEGORY *</asp:ListItem>
</asp:DropDownList>

这在我的本地机器上运行完美,但是当我将它上传到服务器时出现了这个错误:

Server Error in '/' Application.

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1061: 'ASP.categorybrands_aspx' does not contain a definition for 'CatsList_SelectedIndexChanged' and no extension method 'CatsList_SelectedIndexChanged' accepting a first argument of type 'ASP.categorybrands_aspx' could be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 24:                 <div class="service span3" style="background-color:#fff;border:none;margin-bottom:0px;padding-bottom:0px;">                                      
Line 25:                     <h4 style="color:#ff6a00;font-family:Corbel;">Category</h4>
Line 26:                     <asp:DropDownList runat="server" ID="CatsList" AutoPostBack="True" AppendDataBoundItems="True" DataSourceID="CatsDataSource" DataTextField="CatName" DataValueField="CatId" ClientIDMode="Static" OnSelectedIndexChanged="CatsList_SelectedIndexChanged" OnDataBound="CatsList_DataBound">
Line 27:                         <asp:ListItem Value="1">* SELECT CATEGORY *</asp:ListItem>
Line 28:                     </asp:DropDownList>

我的 .cs 文件中有 CatsList_SelectedIndexChanged 方法,我真的不明白这个错误!

最佳答案

好吧,这是一个愚蠢的错误,但我想出了一个简单的解决方案!!

  1. 我清理了我的解决方案。
  2. 再次重建
  3. 重新上传应用。到服务器。

它现在正在工作。

关于c# - 错误 : DropdownList server error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20688202/

相关文章:

c# - HttpApplicationState 在 MVC Controller 中不可用

asp.net - 加载数据库图像的最佳方法

c# - RadListView 控件未指定项目占位符

c# - 在 ASP.NET Core MVC 中使用 Prometheus 的示例项目?

c# - 在 HttpClient 上取消异步和等待不会在 OSX 上抛出异常

c# - EndpointDispatcher 的 ContractFilter 不匹配?

c# - FolderBrowserDialog C# SelectedPath 始终显示在底部

c# - 替换 Xml 节点/元素的内部文本

asp.net - 当必填字段验证器为真时调用 Javascript 函数

asp.net - ASP Core 3 上的 JWT + SignalR 导致 401 未经授权