login.aspx文件

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" >
  4. <head runat="server">
  5. <title>用户登录</title>
  6. </head>
  7. <body>
  8. <form id="form1" runat="server">
  9. <div valign="middle">
  10. <table valign="center" align="center" border="1" cellpadding="0" cellspacing="0" bordercolorlight="#003366" bordercolordark="#ffffff">
  11. <tr id="addData_TR" class="STYLE1" >
  12. <td colspan="2" align="center">
  13. 银行日记帐系统</td>
  14. </tr>
  15. <tr class="STYLE1">
  16. <td>用户名:</td>
  17. <td><input name="userName" type="text" id="Txt_LoginName" runat="server"/>
  18. <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Txt_LoginName"
  19. ErrorMessage="请输入用户名!">*</asp:RequiredFieldValidator></td>
  20. </tr>
  21. <tr class="STYLE1">
  22. <td>
  23. 密    码:</td>
  24. <td><input name="psw" type="password" id="Txt_Password" runat="server" style="width: 149px"/>
  25. <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Txt_Password"
  26. ErrorMessage="请输入密码!">*</asp:RequiredFieldValidator></td>
  27. </tr>
  28. <tr>
  29. <td colspan="2" align="center" style="height: 26px">
  30. <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="登 录" />
  31. <input type="button" value="关 闭" onclick="window.opener=null;window.close();" />
  32. </td>
  33. </tr>
  34. </table>
  35. </div>
  36. </form>
  37. <script type="text/javascript">
  38. var oUserId = document.getElementById("Txt_LoginName");
  39. var oPwd = document.getElementById("Txt_Password");
  40. window.onload = function()
  41. {
  42. oUserId.focus();
  43. oUserId.onkeydown = function ()
  44. {
  45. if(event.keyCode == 13 ) oPwd.focus();
  46. }
  47. }
  48. </script>
  49. </body>
  50. </html>

------------------------------------------------------------------------------------

login.aspx.cs文件

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. public partial class login : System.Web.UI.Page
  13. {
  14. protected SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["Conn"]);
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. }
  18. protected void Button1_Click(object sender, EventArgs e)
  19. {
  20. string sql = "select * from person where name='" + this.Txt_LoginName.Value + "'";
  21. SqlDataAdapter cmd = new SqlDataAdapter(sql, conn);
  22. DataTable dt = new DataTable();
  23. cmd.Fill(dt);
  24. if (dt.Rows.Count == 1)
  25. {
  26. //Session["name"] = dt.Rows[0]["user_name"].ToString();
  27. Session["user_id"] = dt.Rows[0]["name"].ToString();
  28. Session["pwd"] = dt.Rows[0]["password"].ToString();
  29. //Session["flg"] = dt.Rows[0]["flg"].ToString();
  30. if (this.Txt_Password.Value == dt.Rows[0]["password"].ToString().Trim())
  31. {
  32. System.Web.Security.FormsAuthentication.RedirectFromLoginPage(this.Txt_LoginName.Value, false);
  33. this.Response.Redirect("index.aspx");
  34. }
  35. }
  36. if (dt.Rows.Count == 0)
  37. {
  38. this.RegisterStartupScript("T", "<script language=javascript>alert('没有这个账号,请检查输入是否正确!')</script>");
  39. }
  40. else if (dt.Rows.Count > 1)
  41. {
  42. this.RegisterStartupScript("T", "<script language=javascript>alert('账号有重复!')</script>");
  43. }
  44. }
  45. }

------------------------------------------------------------------------------------

index.aspx

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="index" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" >
  4. <head runat="server">
  5. <title>无标题页</title>
  6. </head>
  7. <body>
  8. <form id="form1" runat="server">
  9. <div>
  10. 登陆成功!
  11. </div>
  12. </form>
  13. </body>
  14. </html>

---------------------------------------------------------------------------

index.aspx.cs

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. public partial class index : System.Web.UI.Page
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. }
  16. }

-----------------------------------------------------------------------------------

web.config文件

    1. <?xml version="1.0"?><!--
    2. 注意: 除了手动编辑此文件以外,您还可以使用
    3. Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
    4. “网站”->“Asp.Net 配置”选项。
    5. 设置和注释的完整列表在
    6. machine.config.comments 中,该文件通常位于
    7. \Windows\Microsoft.Net\Framework\v2.x\Config 中
    8. --><configuration>
    9. <appSettings>
    10. <add key="Conn" value="Data Source=localhost;Initial Catalog=dzjc_2005;User ID=sa;Password= " />
    11. <add key="DataBaseType" value="1" />
    12. <!--value为1表示连接的数据库是SQL,2表示oracle-->
    13. <add key="CrystalImageCleaner-AutoStart" value="true" />
    14. <add key="CrystalImageCleaner-Sleep" value="60000" />
    15. <add key="CrystalImageCleaner-Age" value="120000" />
    16. </appSettings>
    17. <system.web>
    18. <!--
    19. 设置 compilation debug="true" 将调试符号插入
    20. 已编译的页面中。但由于这会
    21. 影响性能,因此只在开发过程中将此值
    22. 设置为 true。
    23. -->
    24. <compilation debug="true">
    25. <assemblies>
    26. <add assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
    27. <add assembly="CrystalDecisions.Shared, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
    28. <add assembly="CrystalDecisions.ReportSource, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
    29. <add assembly="CrystalDecisions.Enterprise.Framework, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
    30. <add assembly="CrystalDecisions.Enterprise.Desktop.Report, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
    31. <add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
    32. <add assembly="CrystalDecisions.Enterprise.InfoStore, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/><add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/></assemblies></compilation>
    33. <authorization>
    34. <deny users="?"/>
    35. </authorization>
    36. <authentication mode="Forms">
    37. <forms loginUrl="login.aspx" name=".App" timeout="7200"></forms>
    38. </authentication>
    39. <!--
    40. 通过 <authentication> 节可以配置 ASP.NET 使用的
    41. 安全身份验证模式,
    42. 以标识传入的用户。
    43. -->
    44. <!--<authentication mode="Windows"/>
    45. 如果在执行请求的过程中出现未处理的错误,
    46. 则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
    47. 开发人员通过该节可以配置
    48. 要显示的 html 错误页
    49. 以代替错误堆栈跟踪。
    50. <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
    51. <error statusCode="403" redirect="NoAccess.htm" />
    52. <error statusCode="404" redirect="FileNotFound.htm" />
    53. </customErrors>
    54. -->
    55. <httpHandlers><add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/></httpHandlers></system.web>
    56. <location path="index">
    57. <system.web>
    58. <authorization>
    59. <allow users="*"/>
    60. </authorization>
    61. </system.web>
    62. </location>
    63. </configuration>

asp登陆例子,asp,mssql,登陆的更多相关文章

  1. ASP.NET Core 使用外部登陆提供程序登陆的流程,以及身份认证的流程 (转载)

    阅读目录 在Asp.Net Core 中使用外部登陆(google.微博...) 中间件管道 The Authentication Middleware The Challenge 与认证中间件进行交 ...

  2. Asp.Net中Ajax实现登陆判断

    Default.aspx: <head runat="server"> <title>无标题页</title> <script type= ...

  3. ASP.NET -- WebForm -- Cookie的使用 应用程序权限设计 权限设计文章汇总 asp.net后台管理系统-登陆模块-是否自动登陆 C# 读写文件摘要

    ASP.NET -- WebForm -- Cookie的使用 ASP.NET -- WebForm --  Cookie的使用 Cookie是存在浏览器内存或磁盘上. 1. Test3.aspx文件 ...

  4. javaweb简单登陆例子

    JSP+Servlet+JavaBean简单程序例子——用户名密码登陆,摘自<Tomcat&JavaWeb 技术手册>,亲测可用. IDE环境:MyEclipse10 1.建立We ...

  5. ASP.NET没有魔法——ASP.NET MVC & 分层

    上一篇文章简要说明了MVC所代表的含义并提供了详细的项目及其控制器.视图等内容的创建步骤,最终完成了一个简单ASP.NET MVC程序. 注:MVC与ASP.NET MVC不相等,MVC是一种开发模式 ...

  6. ApsCMS AspCms_SettingFun.asp、AspCms-qqkfFun.asp、AspCms_Slide.asp、AspCms_StyleFun.asp、login.asp、AspCms_CommonFun.asp Vul

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 AspCMS管理系统有较多漏洞,涉及到SQL注入.密码泄漏.后台写SHE ...

  7. ASP.NET没有魔法——ASP.NET Identity 的“多重”身份验证

    ASP.NET Identity除了提供基于Cookie的身份验证外,还提供了一些高级功能,如多次输入错误账户信息后会锁定用户禁止登录.集成第三方验证.账户的二次验证等,并且ASP.NET MVC的默 ...

  8. 介绍 ASP.NET Identity - ASP.NET 应用程序的成员身份认证系统

    ASP.NET Identity 是构建 ASP.NET web 应用程序的一种新的身份认证系统.ASP.NET Identity 可以让您的应用程序拥有登录功能,并可以轻松地自定义登录用户的相关数据 ...

  9. ASP.NET路由[ASP.NET Routing]

    ASP.NET路由[ASP.NET Routing] ASP.NET路由允许你在使用URL时不必匹配到网站中具体的文件,因为这个URL不必匹配到一个文件,你使用了描述用户行为且更容易被用户理解的URL ...

  10. 【转】【Asp.Net】asp.net(c#) 网页跳转

    在asp.net下,经常需要页面的跳转,下面是具体的几种方法.跳转页面是大部编辑语言中都会有的,正面我们来分别介绍一下关于.net中response.redirect sever.execute se ...

随机推荐

  1. Android画一条横线

    <View android:layout_width="match_parent" android:layout_height="1px" android ...

  2. Hibernate缓存机制

    缓存是介于应用程序和物理数据源之间,其作用是为了降低应用程序对物理数据源访问的频次,从而提高了应用的运行性能.缓存内的数据是对物理数据源中的数据的复制,应用程序在运行时从缓存读写数据,在特定的时刻或事 ...

  3. 3.1 关系数据库标准语言SQL综述

    一.SQL语言的特点 SQL结构查询语言 1.综合统一: 2.高度非过程化:不需要指定存储路径 3.面向集合的操作方式 4.以同一种语法提供两种使用方式:独立语言.嵌入式语言 5.语言简单,易学易用 ...

  4. UML类图关系大全

    UML类图关系大全 1.关联 双向关联: C1-C2:指双方都知道对方的存在,都可以调用对方的公共属性和方法.在GOF的设计模式书上是这样描述的:虽然在分析阶段这种关系是适用的,但我们觉得它对于描述设 ...

  5. Android selector选择器的使用

    通常按钮在点击前和后有两种状态,比如点击前为蓝色,点击后为灰色,且不再响应点击事件. 如果不使用selector选择器,点击后,就需要在程序中进行以下的类似操作 button1.setBackgrou ...

  6. httpClient 4.x post get方法

    public static String doPost(String url, String encoding, String contentType, String sendData) throws ...

  7. 如何对ConnectionString进行加密解码?

    这个就不说了就是一个类 public static class EncryptionConfig { /* 加密配置节点 * Response.Write(EncryptionConfig.Encry ...

  8. 【STL】-pair的用法

    初始化: std::pair<int, float> p; //initialize p.first and p.second with zero std::pair<int, co ...

  9. ubuntu安装vim

    1.安装 sudo apt-get install vim-gtk 2.安装完成之后,在命令行敲入vi,按“tab”键,可以看到,已经有vim命令的存在,安装成功. 3.配置 sudo vim /et ...

  10. “人少也能办大事”---K2 BPM老客户交流会

    主题:固铂轮胎工作流项目分享-K2 SmartForm下的工作流快速开发 嘉宾:王彦(固铂轮胎IT资深经理) 国内业务规模越来越大,流程越来越复杂,跨部门跨组织的流程纸质审批非常复杂,内控的要求越来越 ...