zoukankan      html  css  js  c++  java
  • 20151221:Web复习:登陆

    前台HTML代码:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Denglu.aspx.cs" Inherits="Denglu" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
        <style type="text/css">
    
                    * {
                        margin: 0px auto;
                        padding: 0px;
                    }
         </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div id="aa" style="400px">
            <h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h1>
            <h1>&nbsp;</h1>
            <h1>&nbsp;</h1>
            <h1>&nbsp;</h1>
            <h1>&nbsp;</h1>
            <h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 登录</h1>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Label ID="Label1" runat="server" Text="用户名:"></asp:Label>
            <asp:TextBox ID="txtUid" runat="server"></asp:TextBox>
            <br />
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Label ID="Label2" runat="server" Text="密码:"></asp:Label>
            <asp:TextBox ID="txtPwd" runat="server" TextMode="Password"></asp:TextBox>
            <br />
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="Button1" runat="server" Text="登陆" OnClick="Button1_Click" />
        
            <asp:Literal ID="Literal1" runat="server"></asp:Literal>
        
        </div>
        </form>
    </body>
    </html>

    后台C#代码:

    public partial class Denglu : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            TextDataContext context = new TextDataContext();
            //取值
            string uid = txtUid.Text;
            string pwd = txtPwd.Text;
            //查询
            var query = context.login1.Where(p => p.username == uid && p.password == pwd);
            //判断
            if (query.Count() > 0)
            {
                Session["uid"] = uid;
                Response.Redirect("Main.aspx");
            }
            else
            {
                Literal1.Text = "<script type='Text/javascript'>alert('用户名或密码错误!');</script>";
            }
        }
    }

  • 相关阅读:
    为何url地址不是直接发送到服务器,而是被编码后再发送
    http请求分析
    Nginx+Php不支持并发,导致curl请求卡死(Window环境)
    Vue开发调试神器 vue-devtools
    什么是闭包?闭包的优缺点?
    Nginx 504 Gateway Time-out分析及解决方法
    HTTP请求8种方法
    MySQL查询缓存总结
    MySQL单表多次查询和多表联合查询,哪个效率高?
    分布式系统一致性问题解决实战
  • 原文地址:https://www.cnblogs.com/mn-b/p/5074523.html
Copyright © 2011-2022 走看看