网页前台LOGIN.ASPX页面的代码
<%@ Page language="c#"  AutoEventWireup="true" Codebehind="login.aspx.cs" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
<HEAD>
<title>.</title>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK href="css/bxxs.css" rel="stylesheet">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<div class="container">
<!--START: Header -->
<h1 title="AURUM3 Newtech"><IMG height="125" alt="AURUM3 Newtech" src="images/header.jpg" width="738"></h1>
<!--END: Header -->
<table cellSpacing="0" cellPadding="0" width="330" align="center" border="0">
<tr>
<td align="center" colSpan="2" height="10">&nbsp;</td>
</tr>
<tr>
<td align="right" width="40%"><IMG hspace="10" src="images/icon_n1.gif" align="absMiddle" vspace="0">用户名:</td>
<td align="left" width="64%"><FONT face="宋体"><asp:textbox id="tbl_name" runat="server"></asp:textbox></FONT></td>
</tr>
<tr>
<td style="HEIGHT: 36px" vAlign="top" align="right"><IMG hspace="10" src="images/icon_n2.gif" align="absMiddle" vspace="0">密&nbsp;&nbsp;&nbsp;码:</td>
<td style="HEIGHT: 36px" align="left"><asp:textbox id="tbl_pwd" runat="server"></asp:textbox></td>
</tr>
<tr>
<td vAlign="top" align="center" colSpan="2" height="10">&nbsp;</td>
</tr>
<tr>
<td vAlign="top" align="center" colSpan="2" height="55"><asp:button id="btnlogin" OnClick="btnlogin_Click" runat="server" Text="登陆"></asp:button><asp:label id="Message" runat="server" ForeColor="red" Visible="False"></asp:label></td>
</tr>
</table>
</form>
<br style="CLEAR: both">
<!--START: Footer -->
<div class="footer">
<p>&copy; 2007 <a href="http://www.nxtv.cn/" target="_blank">NXTV.CN</a> All rights 
reserved.
</p>
</div>
<!--END: Footer --> </DIV></FORM>
</body>
</HTML>网页login.asp.cs后台代码
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;namespace bxxsNet
{
/// <summary>
/// login 的摘要说明。
/// </summary>
public class login : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox tbl_name;
protected System.Web.UI.WebControls.TextBox tbl_pwd;
protected System.Web.UI.WebControls.Button btnlogin;
protected System.Web.UI.WebControls.Label Message;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
Message.Visible=false;

}
}
private void btnlogin_Click(object sender, System.EventArgs e)
{
if(tbl_name.Text == "" || tbl_pwd.Text == "")
{
Message.Visible = true;
Message.Text = "请输入用户名或密码!";
}
else
{
string strConnection = @"Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("DB_51aspx\\Data.mdb");
OleDbConnection MyConn = new OleDbConnection(strConnection);
MyConn.Open();
string strsql = "select * from NXTV_BxxsAdmin where AdminName = '"+ tbl_name.Text.Trim() +"' and AdminPwd = '"+ tbl_pwd.Text.Trim() +"'";
OleDbCommand MyCmd = new OleDbCommand(strsql,MyConn);
OleDbDataReader dr = MyCmd.ExecuteReader();
if (dr.Read())
{
Session["AdminLevel"] = 1;
Response.Redirect("AdminName.aspx");
}
else
{
Message.Visible = true;
Message.Text = "用户名或密码错误!";
}
} }
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{    
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
}
}
为何总是出现下列问题:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0117: 'ASP.login_aspx' does not contain a definition for 'btnlogin_Click'Source Error: Line 33:  </tr>
Line 34:  <tr>
Line 35:  <td vAlign="top" align="center" colSpan="2" height="55"><asp:button id="btnlogin" OnClick="btnlogin_Click" runat="server" Text="鐧婚檰"></asp:button><asp:label id="Message" runat="server" ForeColor="red" Visible="False"></asp:label></td>
Line 36:  </tr>
Line 37:  </table>
 Source File: d:\Work\FoosunCMS_32sp1_Free\bxxsNet\login.aspx    Line: 35 

解决方案 »

  1.   

    'btnlogin_Click'  这个方法没定义 
    你按钮的事件重新弄下 
      

  2.   

    'btnlogin_Click'  请问这个方法该如何定义
      

  3.   

    在 private void InitializeComponent() 里面添加
    this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click);
    就行咯...试试吧...其实这个应该是自动生成的...应该是你删了吧...
      

  4.   

    建议你把这个Button删除掉,重新拖一个,在重新注册下!
      

  5.   

    那你在
     private void InitializeComponent() 里面添加 
    this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click);