Error CS1601 from ASP.NET Application, but can't see why
I'm working my way through this tutorial here about progress dialogues but have hit an elementary problem I can't see the cause of. The my project so far returns the error message...
Compiler Error Message: CS1061: 'ASP.webprogressbar_aspx' does not contain a
definition for 'Button1_Click' and no extension method 'Button1_Click' accepting
a first argument of type 'ASP.webprogressbar_aspx' could be found (are you
missing a using directive or an assembly reference?)
Source Error:
Line 12: <legend>WebProgressBar</legend>
Line 13: <div>
Line 14: <asp:Button id="Button1"
Line 15: runat="server"
Line 16: Text="Start Long Task!"
The project so far is (in its entirety), the WebProgressBar.aspx
<%@ Page Language="C#"
AutoEventWireup="true"
CodeBehind="WebProgressBar.aspx.cs"%>
<html>
<head id="Head1" runat="server">
<title> </title>
</head>
<body>
<form id="form1" runat="server">
<fieldset>
<legend>WebProgressBar</legend>
<div>
<asp:Button id="Button1"
runat="server"
Text="Start Long Task!"
OnClick="Button1_Click">
</asp:Butto开发者_如何学Pythonn>
</div>
</fieldset>
</form>
</body>
</html>
and the WebProgressBar.aspx.cs...
using System;
public partial class WebProgressBar : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void Button1_Click(object sender, EventArgs e)
{
Session["State"] = 1;
}
}
Can anyone see what I have overlooked?
I think you're missing the Inherits
attribute in your <%@ Page
statement.
<%@ Page ... Inherits="WebProgressBar" %>
you seem to be missing the tag to inherit a class. Essentially it can't find the event handlers for your button since the class hasn't been listed.
<%@ Page Language="C#" AutoEventWireup="true" Inherits="WebProgressBar" CodeBehind="WebProgressBar.aspx.cs"%>
精彩评论