20151223:web: Audit: Login

Source: Internet
Author: User

ASPX code:

<%@ Page Language="C #"AutoEventWireup="true"CodeFile="DengLu.aspx.cs"Inherits="Denglu" %><!DOCTYPE HTML><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Headrunat= "Server"><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"/>    <title></title>    <style>. DL{margin:0px Auto;padding:0px; Left:400px;width:304px;Height:257px;    }</style></Head><Body>    <formID= "Form1"runat= "Server">    <Divclass= "DL">        <H1>&nbsp;&nbsp;&nbsp;Login</H1>        <P>&nbsp;</P>        <P>            &nbsp;            <Asp:labelID= "Label1"runat= "Server"Text= "User name:"></Asp:label>            <Asp:textboxID= "TextBox1"runat= "Server"></Asp:textbox>        </P>        <P>            &nbsp;&nbsp;            <Asp:labelID= "Label2"runat= "Server"Text= "Password:"></Asp:label>            <Asp:textboxID= "TextBox2"runat= "Server"></Asp:textbox>        </P>        <P>            &nbsp;&nbsp;&nbsp;&nbsp;        </P>        <P>            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            <Asp:buttonID= "Button1"runat= "Server"Text= "Login"OnClick= "Button1_Click" />            <asp:literalID= "Literal1"runat= "Server"></asp:literal>        </P>    </Div>    </form></Body></HTML>

CS Code:

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls; Public Partial classdenglu:system.web.ui.page{PrivateUsersdatacontext context =NewUsersdatacontext (); protected voidPage_Load (Objectsender, EventArgs e) {    }    protected voidButton1_Click (Objectsender, EventArgs e) {        //Take value        stringUID =TextBox1.Text; stringPWD =TextBox2.Text; //Check the database        varquery = Context.users.Where (p = p.username = = UID && P.password = =pwd); if(Query. Count () >0)        {            intState =query. First ().            State.value; if(state = =0) {Literal1.text="<script type= ' text/javascript ' >alert (' This account is not approved! ');</script>"; }            Else if(state = =1) {session["UID"] =uid; Response.Redirect ("main.aspx"); }            Else{Literal1.text="<script type= ' text/javascript ' >alert (' This account failed to audit! ');</script>"; }                 }        Else{Literal1.text="<script type= ' text/javascript ' >alert (' username or password is wrong! ');</script>"; }    }}

20151223:web: Audit: Login

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.