Easyui-Backend Management system-Login module

Source: Internet
Author: User

Effect:

---

---

HTML code:

<div id="Login"> <p> account: <input type="text"Id="User"/></p> <p> Password: <input type="Password"Id="pwd"/></p> </div> <div id="btn"> <a id="Submit"href="#" class="Easyui-linkbutton"> Login </a> </div>

CSS code:

#login {    000;} p {    height:22px;    line-height:22px;     0 0 45px;} #user, #pwd {    height:22px;    padding:0  2px;    border:1px solid #8ac8f5;} #btn {    text-align:center;}. Easyui-LinkButton {    padding:0  10px;}

JS Code:

    • For security reasons, the password is MD5 encrypted operation, the detailed operation see: http://www.cnblogs.com/KTblog/p/4939932.html
$ (function () {//Login Form$('#login'). Dialog ({title:'Background Login', Width: -, Height: the, Iconcls:'Icon-login', modal:true, closable:false, draggable:false, buttons:'#btn',    }); //Verify account text box$('#user'). Validatebox ({required:true, Missingmessage:'The text box cannot be empty! ', Invalidmessage:'the input is not correct, please re-enter! ',    }); //Verify password text box$('#pwd'). Validatebox ({required:true, Validtype:'length[6, ()', Missingmessage:'The text box cannot be empty! ', Invalidmessage:'the password is 6-20! ',    }); //when loading, verify the text box    if(!$('#user'). Validatebox ('IsValid')) {        $('#user'). focus (); }    Else if(!$('#pwd'). Validatebox ('IsValid')) {        $('#pwd'). focus (); }    //Click the Login button event$('#submit'). Click (function () {//Remove all spacesString.prototype.NoSpace =function () {return  This. replace (/\s+/g,"");        }; //if not verified successfully, move the cursor to the text box.         if(!$('#user'). Validatebox ('IsValid')) {            $('#user'). focus (); }        Else if(!$('#pwd'). Validatebox ('IsValid')) {            $('#pwd'). focus (); }        Else {            //gets the contents of the text box and uses Ajax to submit            varUser = $ ('#user'). Val ().            Nospace (); varPWD = $ ('#pwd'). Val ().            Nospace (); //MD5 EncryptionPWD =$.md5 (PWD); //Prompt progress bar$.messager.progress ({width: -, Text:'Verifying login [{value}]% ... ........',            }); //Ajax Background Verification$.ajax ({type:'Post', URL:'.. /application/ashx/validlogin.ashx', data: {User:user, Pwd:pwd,}, //determine the value returnedsuccess:function (data) {if(Data = =1) {$.messager.alert ("Tips","have this user! "); $.messager.progress ('Close'); } Else if(Data = =0) {$.messager.alert ("Tips","no such user! "); $.messager.progress ('Close'); } Else if(Data = =-1) {$.messager.alert ("Tips","Server exception, please contact the administrator! "); $.messager.progress ('Close'); } Else{$.messager.alert ("Tips","Browser exception, please contact the administrator! "); $.messager.progress ('Close');        }                }            }); }    });}) 

Background Server code:

usingSystem.Threading;usingsystem.web;usingSystem.Web.SessionState;namespaceeasyui.application.ashx{/// <summary>    ///Summary description of Validlogin/// </summary>     Public classValidlogin:ihttphandler, IRequiresSessionState {/// <summary>        ///return value/// </summary>        enumreturnvalue {selectuser=1,//have usersNoselectuser =0,//no user foundWeberror =-1//Error        }         Public voidProcessRequest (HttpContext context) {Thread.Sleep ( the);//Sleep 3s//Get account/password            stringUser = context. request["User"]; stringPWD = context. request["pwd"]; //Validation            Try            {                //Verify that the account password is correct                if(User = ="123"&& pwd = ="Mimamima") {context. Response.Write ((int) returnvalue.selectuser); //If the user exists, save the session. Context. session["User"] =user; }                Else{context. Response.Write ((int) returnvalue.noselectuser); }            }            Catch{context. Response.Write ((int) returnvalue.weberror); }        }         Public BOOLisreusable {Get            {                return false; }        }    }}

Easyui-Backend Management system-Login module

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.