这是一个登录页面的前台代码。<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %><!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 runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div style="text-align: center">
            <table style="width: 300px; height: 100px; border-right: #009900 1px solid; border-top: #009900 1px solid; font: menu; border-left: #009900 1px solid; border-bottom: #009900 1px solid;">
                <tr>
                    <td colspan="2" style="border-right: #00cc00 1px dashed; border-top: #00cc00 1px dashed; font: menu; border-left: #00cc00 1px dashed; width: 100%; border-bottom: #00cc00 1px dashed; height: 22px; background-color: aliceblue">
                        管理登陆</td>
                </tr>
                <tr>
                    <td style="width:43px; border-right: #00cc00 1px dashed; border-top: #00cc00 1px dashed; font: menu; border-left: #00cc00 1px dashed; border-bottom: #00cc00 1px dashed; height: 21px; background-color: aliceblue;">
                        用户名:</td>
                    <td style="width: 41px; border-right: #00cc00 1px dashed; border-top: #00cc00 1px dashed; font: menu; border-left: #00cc00 1px dashed; border-bottom: #00cc00 1px dashed; height: 21px; background-color: aliceblue;" align="left">
                        <asp:TextBox ID="TextBox1" runat="server" Style="border-right: #009900 1px solid;
                            border-top: #009900 1px solid; font: menu; border-left: #009900 1px solid; border-bottom: #009900 1px solid" Width="100px"></asp:TextBox>
                        </td>
                </tr>
                <tr>
                    <td style="width: 43px; height: 21px; border-right: #00cc00 1px dashed; border-top: #00cc00 1px dashed; font: menu; border-left: #00cc00 1px dashed; border-bottom: #00cc00 1px dashed; background-color: aliceblue;">
                        密 &nbsp;&nbsp; 码:</td>
                    <td style="width: 41px; height: 21px; border-right: #00cc00 1px dashed; border-top: #00cc00 1px dashed; font: menu; border-left: #00cc00 1px dashed; border-bottom: #00cc00 1px dashed; background-color: aliceblue;" align="left">
                        <asp:TextBox ID="TextBox2" runat="server"  Style="border-right: #009900 1px solid;
                            border-top: #009900 1px solid; font: menu; border-left: #009900 1px solid; border-bottom: #009900 1px solid" TextMode="Password" Width="100px"></asp:TextBox>
                        </td>
                </tr>
                <tr>
                    <td colspan="2" style="height: 16px; border-right: #00cc00 1px dashed; border-top: #00cc00 1px dashed; font: menu; border-left: #00cc00 1px dashed; width: 100%; border-bottom: #00cc00 1px dashed; background-color: aliceblue;" align="center">
                        <asp:Button ID="Button1" runat="server" Style="font: menu; background-color: whitesmoke"
                            Text="登  陆" OnClick="Button1_Click" /></td>
                </tr>
            </table>
        </div>
    
    </div>
    </form>
</body>
</html>
这是登录页面的后台代码:using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class login : System.Web.UI.Page
{
//download from 51aspx.com
    protected void Page_Load(object sender, EventArgs e)
    {    }
    protected void Button1_Click(object sender, EventArgs e)
    {
          string login_name=ConfigurationSettings.AppSettings["login_name"];
          string pwd = ConfigurationSettings.AppSettings["pwd"];
        if(login_name==this.TextBox1.Text&&pwd==this.TextBox2.Text)
          {
              Session["admin"] = "binbin";
            Response.Redirect("index.aspx");
        }
          else
          {
             Response.Redirect("login.aspx");
        }    }
}为什么没看到前台,在哪个地方调用了后台定义的这些函数呢,会自动执行吗

解决方案 »

  1.   

      <asp:Button ID="Button1" runat="server" Style="font: menu; background-color: whitesmoke"
      Text="登 陆" OnClick="Button1_Click" /></td>这个就是前台调用后台Button1_Click 事件的地方 Page_Load不需要前台调用,页面加载的时候会自动执行
      

  2.   

    <asp:Button ID="Button1" runat="server" Style="font: menu; background-color: whitesmoke"
      Text="登 陆" OnClick="Button1_Click" />在这呢
      

  3.   

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>这句里面,codefile就是关联你的cs页面的,将aspx页面和cs页面连接