62,046
社区成员
发帖
与我相关
我的任务
分享
<%--<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="helloweb._Default" %>--%>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="helloweb._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>
<br />
<table>
<tr>
<td style="width: 100px">
<asp:Label ID="Label1" runat="server" Text="Email Address"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="UserName" runat="server"></asp:TextBox></td>
<td style="width: 172px">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Email Address Required" ControlToValidate="UserName" Font-Strikeout="True"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid Email Format" ControlToValidate="UserName" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td style="width: 100px; height: 26px;">
<asp:Label ID="Label2" runat="server" Text="Password"></asp:Label></td>
<td style="width: 100px; height: 26px;">
<asp:TextBox ID="Password" runat="server"></asp:TextBox></td>
<td style="width: 172px; height: 26px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Password Required" ControlToValidate="Password"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 100px; height: 26px">
<asp:Label ID="Label3" runat="server" Text="Re-Enter Password"></asp:Label></td>
<td style="width: 100px; height: 26px">
<asp:TextBox ID="Password2" runat="server" OnTextChanged="Password2_TextChanged"></asp:TextBox></td>
<td style="width: 172px; height: 26px">
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Passwords do not match" ControlToCompare="Password" ControlToValidate="Password2"></asp:CompareValidator></td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td style="width: 100px">
<asp:Button ID="LogIn" runat="server" OnClick="LogIn_Click" Text="Log in" /></td>
<td style="width: 172px">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
ShowSummary="False" HeaderText="出错啦" />
</td>
</tr>
</table>
</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;
namespace helloweb
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Response.Write("<h1>You r now Logged in</h1>");
}
protected void LogIn_Click(object sender, EventArgs e)
{
if (UserName.Text == "jason@fladotnet.net"
&& Password.Text == "password")
{
Response.Redirect(@"Success.aspx");
}
//following is the code which is old but ok.
//Response.Write(UserName.Text);
//Response.Write("<br>");
//Response.Write(Password.Text);
//Response.End();
}
protected void Password2_TextChanged(object sender, EventArgs e)
{
}
}
}