Home >Web Front-end >JS Tutorial >ExtJs form submission login implementation code_extjs

ExtJs form submission login implementation code_extjs

WBOY
WBOYOriginal
2016-05-16 18:21:081305browse
1 Add a click submit event in the subclass
Copy the code The code is as follows:

//Login button click event
loginFun: function() {
var f = Ext.getCmp("loginForm");
//Form verification
if (f.form .isValid) {
f.form.submit({
waitTitle: "Please wait",
waitMsg: 'Logging in...',
url: 'http://www. cnblogs.com/Service/SystemService/SystemService.ashx?Method=UserLogin',
method: 'POST',
success: function(form, action) {
window.location = 'Main.htm'
},
failure: function(form, action) {
if (action.result == undefined) {
Ext.Msg.alert('Prompt', "System error... Please Contact the administrator");
form.items.items[1].reset();
}
else {
Ext.Msg.alert('prompt', action.result.rspText) ;
form.items.items[1].reset();
}
}
});
}
},

2 Bind the event to the login button in the initialization
Copy the code The code is as follows:

//Initialization
init: function() {
this.LoginWin.show();
Ext.getCmp("loginBtn").on('click', this.loginFun);
this.loadMask = new Ext.LoadMask(this.LoginWin.body, { msg: "The page is loading..." });
}

3. About ext .extend
Definition: function extend(function sb, function sp,Object overrides)
Simple explanation: the first parameter--subclass
The second parameter--parent class
The third parameter - overriding object
In the example, the subclass is XQH.ExtJs.Frame.app
Provide a public interface. )
For a more detailed introduction, please see (redirected) http://wangyu.javaeye.com/blog/210849
4.url: 'http://www.jb51.net/Service/SystemService/ SystemService.ashx?Method=UserLogin'
Copy code The code is as follows:

public void UserLogin()
{
StringBuilder jsonData = new StringBuilder();
bool success = false;
string rspText = string.Empty;
if (Request["LoginName"] != null && Request["LoginPsd"] != null)
{
string loginName = Request["LoginName"].Trim();
string loginPsd = Request["LoginPsd"].Trim();
XUser userEnity = userAccess.GetUserByName(loginName);
if (userEnity != null)
{
if (userEnity.LoginPsd == loginPsd)
{
success = true;
Session["UserEnity"] = userEnity;
}
else
{
success = false;
rspText = "Wrong account or password";
}
}
else
{
success = false;
rspText = "The account does not exist, please contact the administrator";
}
JsonConvert json = new JsonConvert ();
jsonData = json.ToRequest(success, rspText, userEnity);
}
Response.Write(jsonData);
Response.End();
}

Note: The returned data must be success in Json format. rspText is the returned tag and is called in js through action.result.success
Let’s stop here today and implement the background interface framework next time.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn