jetway_loves_programming之c#初学——登录界面程序
来源:互联网 发布:mac 终端命令大全 编辑:程序博客网 时间:2024/04/30 10:24
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>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 251px" id="Label1">
<asp:Label ID="Label7" runat="server" Font-Size="XX-Large" ForeColor="Maroon"
Height="35px" style="margin-left: 186px" Text="请登录" Width="103px"></asp:Label>
<br />
<br />
<asp:Label ID="Label2" runat="server" Font-Size="X-Large" ForeColor="#CC00CC"
Height="27px" style="margin-left: 90px" Text="用户:" Width="90px"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Height="21px"></asp:TextBox>
<asp:RequiredFieldValidator ID = "RequiredFieldValidator1"
ControlToValidate = "TextBox1"
Display = "Dynamic"
ErrorMessage = "不能为空"
runat = "server" />
<br />
<br />
<asp:Label ID="Label3" runat="server" Font-Size="X-Large" ForeColor="#CC3399"
Height="27px" style="margin-left: 90px" Text="密码:" Width="87px"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" style="margin-left: 2px"></asp:TextBox>
<asp:RequiredFieldValidator ID = "RequiredFieldValidator2"
ControlToValidate = "TextBox2"
ErrorMessage = "密码不能为空"
runat = "server" />
<br />
<br />
<asp:CheckBox ID="Persist" runat="server" style="margin-left: 172px"
Text="记住密码" Width="120px" oncheckedchanged="Persist_CheckedChanged" />
<br />
<asp:Button ID="Submit1" OnClick="Login_Click" runat="server" Text="登陆"
Font-Names="黑体" Font-Size="X-Large" Height="42px" style="margin-left: 83px"
Width="76px" />
<asp:Label ID="Label4" runat="server" style="margin-left: 35px" Width="200px"></asp:Label>
</div>
</form>
</body>
</html>
Login.aspx.cs文件中,代码如下:
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Login_Click(object sender, EventArgs e) { if ((TextBox1.Text == "sa") && (TextBox2.Text == "sa")) { FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, Persist.Checked); } else{ Label4.Text = "验证不成功,请再试一次"; } } } 代码参考如上,测试过应该没什么问题,当然了,之前还要在web.config中写入如下代码: <authentication mode="Forms"> <forms loginUrl="Login.aspx" name=".aspsafetest"> </forms> </authentication> <authorization> <deny users="?"/> </authorization> 然后把更改页面的form id,如上文中已经加上了form id="form1"的字样,个人认为这表示的是程序执行时的登录顺序。
- jetway_loves_programming之c#初学——登录界面程序
- jetway_loves_programming之c#初学——如何利用asp.net生成word
- C#初学界面参考小程序
- C#之登录界面详解
- jetway_loves_programming——windows7下安装配置sql server2000
- 初学JSP与Servlet之登录界面1.0版本
- 初学JSP与Servlet之登录界面2.0版本
- 初学JSP与Servlet之登录界面3.0版本
- C#小项目之登录界面1
- 即时内部聊天程序——登录界面
- C#写的简单的登录界面程序
- C#开发程序登录界面用户名和密码的验证
- C# 关于登录界面与主界面,关闭主界面程序不关闭的解决办法
- Android开发之登录界面——记住密码
- Java小程序之GUI开发简单前台登录界面
- 界面编程之登录界面
- Android初学——开机宣传界面
- c#初学之petshop!
- 寻求ACM-ICPC方面的东东
- C++的一些细节
- kqueue example
- SQL2005 With as 公用表表达式,实现递归取数
- 《VC++专题研究》系列之-1- 本系列课程综述
- jetway_loves_programming之c#初学——登录界面程序
- 快速无符号整数开方
- 《VC++专题研究》系列之- 武装你的力量
- ubuntu openfetion-all-2.1.0.tar.gz 安装方法
- sql语句
- FreeBSD kqueue 这种多路复用 IO 模型的用法
- 【镜像相关】虚拟机、LIVECD及其他
- Android开源项目源码下载
- SQLite移植和使用