编译器错误消息:CS1061:
Compiler Error Message: CS1061:
我有一个下拉列表,必须显示文件夹中的图像文件名,但是当我 运行 页面出现此错误时:
Compiler Error Message: CS1061: 'ASP.pagesnew_managementpages_manageproducts_aspx' does not contain a definition for 'ddImage_SelectedIndexChanged' and no extension method 'ddImage_SelectedIndexChanged' accepting a first argument of type 'ASP.pagesnew_managementpages_manageproducts_aspx' could be found (are you missing a using directive or an assembly reference?)
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ManageProducts.aspx.cs" Inherits="PagesNew_ManagementPages_ManageProducts" %>
错误的标签:
Image:</p>
Line 25: <p>
Line 26: <asp:DropDownList ID="ddImage" runat="server" OnSelectedIndexChanged="ddImage_SelectedIndexChanged">
Line 27: </asp:DropDownList>
Line 28: </p>
这是整个文件:
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p>
Name:</p>
<p>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</p>
<p>
Type:</p>
<p>
<asp:DropDownList ID="ddType" runat="server" DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Id">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [ProductTypes] ORDER BY [Name]"></asp:SqlDataSource>
</p>
<p>
Price:</p>
<p>
<asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
</p>
<p>
Image:</p>
<p>
<asp:DropDownList ID="ddImage" runat="server" OnSelectedIndexChanged="ddImage_SelectedIndexChanged">
</asp:DropDownList>
</p>
<p>
Description:</p>
<p>
<asp:TextBox ID="txtDescription" runat="server" Height="72px" TextMode="MultiLine" Width="223px"></asp:TextBox>
</p>
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</p>
<p>
<asp:Label ID="lblResult" runat="server"></asp:Label>
</p>
</asp:Content>
我不明白怎么了?
是的,select 下拉菜单,转到其属性,点击事件并双击显示 onSelectedindexChanged 的位置,VS 将创建事件的定义并将您定向到其光标。
在里面写一行简单的代码,看看能不能编译通过。
如果您已经这样做了,在事件上放置一个断点,启用从工具抛出的异常,然后 运行 通过事件,它应该会为您提供更详细的消息,说明失败的原因。
我有一个下拉列表,必须显示文件夹中的图像文件名,但是当我 运行 页面出现此错误时:
Compiler Error Message: CS1061: 'ASP.pagesnew_managementpages_manageproducts_aspx' does not contain a definition for 'ddImage_SelectedIndexChanged' and no extension method 'ddImage_SelectedIndexChanged' accepting a first argument of type 'ASP.pagesnew_managementpages_manageproducts_aspx' could be found (are you missing a using directive or an assembly reference?)
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ManageProducts.aspx.cs" Inherits="PagesNew_ManagementPages_ManageProducts" %>
错误的标签:
Image:</p>
Line 25: <p>
Line 26: <asp:DropDownList ID="ddImage" runat="server" OnSelectedIndexChanged="ddImage_SelectedIndexChanged">
Line 27: </asp:DropDownList>
Line 28: </p>
这是整个文件:
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p>
Name:</p>
<p>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</p>
<p>
Type:</p>
<p>
<asp:DropDownList ID="ddType" runat="server" DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Id">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [ProductTypes] ORDER BY [Name]"></asp:SqlDataSource>
</p>
<p>
Price:</p>
<p>
<asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
</p>
<p>
Image:</p>
<p>
<asp:DropDownList ID="ddImage" runat="server" OnSelectedIndexChanged="ddImage_SelectedIndexChanged">
</asp:DropDownList>
</p>
<p>
Description:</p>
<p>
<asp:TextBox ID="txtDescription" runat="server" Height="72px" TextMode="MultiLine" Width="223px"></asp:TextBox>
</p>
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</p>
<p>
<asp:Label ID="lblResult" runat="server"></asp:Label>
</p>
</asp:Content>
我不明白怎么了?
是的,select 下拉菜单,转到其属性,点击事件并双击显示 onSelectedindexChanged 的位置,VS 将创建事件的定义并将您定向到其光标。
在里面写一行简单的代码,看看能不能编译通过。
如果您已经这样做了,在事件上放置一个断点,启用从工具抛出的异常,然后 运行 通过事件,它应该会为您提供更详细的消息,说明失败的原因。