来自ASP.NET应用程序的错误CS1601,但看不到原因 [英] Error CS1601 from ASP.NET Application, but can't see why

查看:87
本文介绍了来自ASP.NET应用程序的错误CS1601,但看不到原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过本教程此处关于进度对话,但遇到了一个基本问题,我看不出原因.到目前为止,我的项目返回错误消息...

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!"

到目前为止,该项目(全部)是WebProgressBar.aspx

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:Button>
    </div>
  </fieldset>
</form>
</body>
</html>

和WebProgressBar.aspx.cs ...

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?

推荐答案

您似乎缺少继承类的标签.本质上,由于未列出该类,因此找不到按钮的事件处理程序.

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"%>

这篇关于来自ASP.NET应用程序的错误CS1601,但看不到原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆