zoukankan      html  css  js  c++  java
  • WB 例子 登录

    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>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
               <h1>登录</h1>
            <asp:Label ID="Label1" runat="server" Text="用户名:"></asp:Label>
            <asp:TextBox ID="txtUid" runat="server"></asp:TextBox>
            <br />
            <br />
            <asp:Label ID="Label2" runat="server" Text="密码:"></asp:Label>
            <asp:TextBox ID="txtPwd" runat="server"></asp:TextBox>
            <br />
            <br />
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="登录" />
            <br />
        </div>
            <asp:Literal ID="Literal1" runat="server"></asp:Literal>
        </form>
    </body>
    </html>
    

      后台C#代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class DengLu : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            testDataContext context = new testDataContext();
    
            //取值
            string uid = txtUid.Text;
            string pwd = txtPwd.Text;
            //查询
            var query = context.Login.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>";
            }
        }
    }
    

      网页显示:

  • 相关阅读:
    均匀分布
    吉布斯采样(Gibbs采样)
    蒙特卡罗方法 Monte Carlo method
    马尔科夫链
    python 3 没有了xrange
    %matplotlib inline的含义
    MCMC采样和M-H采样
    pycharm 安装模块 use the correct version of 'pip' installed for your Python interpreter
    Pycharm安装第三方库时出现Read timed out的解决办法
    如何在Pycharm中添加新的模块(第三方包)
  • 原文地址:https://www.cnblogs.com/zhuxu/p/5064771.html
Copyright © 2011-2022 走看看