日期:2014-05-18  浏览次数:20779 次

----------- vs2008不知道我是新手?太坑爹 ------------
C# code
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)
        {
           
        }
       
    }
}


------解决方案--------------------
加个表单试试。 <form id="form1" runat="server">
------解决方案--------------------
注意XHTML语句要完整,你漏掉了</head> <form> <div>,但这不应该是出错的根源。要通过编译很简单,删掉两个button和后台的两个EventHandler。然后重新加上两个Button,并双击Button产生EventHandler即可。
HTML code

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

------解决方案--------------------
楼上+1
小弟我要通过代码删除桌面的快捷方式,但是找不到