OK, or as before, build a login.html page, to fill in the login information, and then build a dealdata.aspx page (of course, here with the general processing is the best: *.ashx), used for processing data.
In the login.html page, the code is as follows:
Copy Code code as follows:
<title> No Refresh login </title>
<script src= "Scripts/jquery-1.4.1.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >
$ (function () {
Element Binding Global Ajaxstart Event
$ ("#divMsg"). Ajaxstart (function () {
$ (this). Show (); Show what's inside span
})
Element Binding Global Ajaxstop Event
$ ("#divMsg"). Ajaxstop (function () {
$ (this). HTML ("Request processing is complete!"). "). Hide ();
})
$ ("#btnSure"). Click (function () {//Click button Event
var $name = $ ("#txtName");//Get Login name
var $pwd = $ ("#txtPwd");//Get password
if ($name. val ()!= "" && $pwd. Val ()!= "") {
Invoke the login () method
Login ($name. Val (), $pwd. Val ());
} else {
if ($name. val () = "") {//If the sign-in name is not empty
Alert ("Logon name cannot be empty!") ");
$name. focus ()//Get focused
return false;
} else {
Alert ("Password cannot be blank!") ");
$pwd. focus ();
return false;
}
}
})
})
function Login (name, password) {
$.ajax ({
Type: "POST",//The way the data is requested (post or get), default to get
URL: "Dealdata.aspx",//Send the requested address (default = Current page)
Data: "action=login&date=" + new Date () + "&name=" + name + "&pwd=" + password,//sent to the server
Data returned after a successful login
Success:function (data) {
if (data = = "True") {//based on the return value (Note: Ture should be wrong to write True)! )
Alert ("Login succeeded!") ");
window.location = "1.htm"; page to jump
} else {
Alert ("Logon name or password is wrong!) ");
return false;
}
}
});
}
</script>
<body style= "Text-align:center" >
<div> Login Name: <input type= "text" id= "txtname" value= ""/></div>
<br/>
<div> Password: <input type= "text" id= "txtpwd" value= ""/></div><br/>
<div>
<input type= "Reset" value= "OK" id= "Btnsure"/>
</div>
<span id= "divmsg" style= "Display:none;" > Sending Request ......</span>
</body>
In dealdata.aspx, its background code is as follows:
Copy Code code as follows:
public partial class ManageData:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
String name = System.Web.HttpUtility.UrlDecode (request["name");//Get Login name
string pwd = System.Web.HttpUtility.UrlDecode (request["pwd");//Get password
Response.Write (Login (name, pwd));
Response.End ();
}
private bool Login (string name, string pwd)
{
BOOL result = FALSE;
if (name = = "Vegetable" && pwd== "123456")
{
return true;
}
return result;
}
}
Well, children's shoes, you also hurriedly try it! No refresh, you can also!