登录界面如图:
_login.aspx代码如下:
<%@ 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>
<script type="text/javascript">//用于检测用户名不为空;
function checkUID() {
var _result = false;
var _txt = document.getElementById("txt_uid");
if (_txt.value != null) { _result = true; }
return _result;
}
</script>
</head>
<body>
<form id="form1" runat="server" defaultbutton="btn_login"
defaultfocus="txt_uid">
<div>
请输入用户名:<asp:TextBox ID="txt_uid" runat="server"></asp:TextBox><asp:Button ID="btn_login"
runat="server" Text="登录" OnClientClick="Return checkUID"
οnclick="Button1_Click" />
</div>
</form>
</body>
</html>
_login.aspx.cs代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["uid"] = txt_uid.Text;
Server.Transfer("_room.aspx");
}
}
登录成功后的页面如图: