vs2008环境,编译器错误消息: CS0117: “ASP.input_aspx”并不包含“Button1_Click”的定义
行 15:  <asp:Button ID="Button1" runat="server" Text="确认提交" onclick="Button1_Click" />
如果把“确认提交”及“放弃退出”部分注释掉就正常,错在哪里?怎么改?
Input.aspx文件:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Input.aspx.cs" Inherits="WebApplication1.Input" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head >
    <title>测试</title><body>
    <table  border="0"   style="text-align: center" "z-index 100; left: 300px; width: 350px; position: static; top: 947px">
   <tr>
  <%-- <td style="width: 230px; text-align: center;">
       <asp:Button ID="Button1" runat="server" Text="确认提交" onclick="Button1_Click" />
       </td>
       <td style="width: 230px; text-align: center;">
       <asp:Button ID="Button2" runat="server" Text="放弃退出" onclick="Button2_Click" />
       </td>--%>
    </tr>
 </table>
    </div>
       </form>
</body>
</html>input.aspx.cs文件:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;namespace WebApplication1
{
    public partial class Input : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {        }        protected void Button1_Click(object sender, EventArgs e)
        {
   
        }        protected void Button2_Click(object sender, EventArgs e)
        {
           
        }
       
    }
}

解决方案 »

  1.   

    这个,应该是误删Button1_Click事件所致,不过看代码这个事件还在的啊
      

  2.   

    加个表单试试。 <form id="form1" runat="server">
      

  3.   

    注意XHTML语句要完整,你漏掉了</head> <form> <div>,但这不应该是出错的根源。要通过编译很简单,删掉两个button和后台的两个EventHandler。然后重新加上两个Button,并双击Button产生EventHandler即可。<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Input.aspx.cs" Inherits="WebApplication5.Input" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>测试</title>
    </head>
    <body>
      <form>
      <div>
        <table  border="0"   style="text-align: center" "z-index 100; left: 300px; width: 350px; position: static; top: 947px">
            <tr>
                <td style="width: 230px; text-align: center;">
                    <asp:Button ID="Button1" runat="server" Text="确认提交" onclick="Button1_Click" />
                </td>
                <td style="width: 230px; text-align: center;">
                    <asp:Button ID="Button2" runat="server" Text="放弃退出" onclick="Button2_Click" />
                </td>
            </tr>
        </table>
      </div>
      </form>
    </body>
    </html>
      

  4.   

    谢谢楼上:试试还是那提示。
    本身在设计视图中添加两个按钮,都正常,但把按钮的“Text”改为“确认提交”后保存运行就会出那样的错误提示。
      

  5.   

    肯定是系统了(操作系统,或VS2008)。因为我测试过你的程序,在我的机器上没有任何问题的,尽管你溜掉了部分HTML代码,那是没有关系的。