首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

- vs2008不知道小弟我是新手?太坑爹 -

2012-08-26 
----------- vs2008不知道我是新手?太坑爹 ------------C# codevs2008环境,编译器错误消息: CS0117: “ASP.

----------- 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
------解决方案--------------------


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

热点排行