當前位置:編程學習大全網 - 編程語言 - 做壹個登錄頁面,如果輸入正確的用戶名和密碼,則進入歡迎頁面,否則錯誤。請寫出主要事件的程序代碼

做壹個登錄頁面,如果輸入正確的用戶名和密碼,則進入歡迎頁面,否則錯誤。請寫出主要事件的程序代碼

Default1.aspx窗體代碼:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>

用戶名:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<br />

<br />

密 碼:

<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

<br />

<br />

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="密碼" Width="116px" /></div>

</form>

</body>

</html>

代碼窗體的代碼如下:

using System;

using System.Data;

using System.Configuration;

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 _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Button1_Click(object sender, EventArgs e)

{

if (TextBox1.Text == "admin" && TextBox2.Text == "admin")

{ Response.Redirect("res/Default2.aspx"); }

else

{ Response.Write("登陸失敗"); }

}

}

  • 上一篇:大衛·勞姆為哪個俱樂部效力?當地有哪些著名景點?
  • 下一篇:診斷卡在測試主板時會用到內存、CPU和顯卡嗎?
  • copyright 2024編程學習大全網