ExtJs form submission Login Implementation code _EXTJS

Source: Internet
Author: User
Tags extend
1 Adding a click Commit event in a subclass
Copy Code code as follows:

Login button Click event
Loginfun:function () {
var f = ext.getcmp ("LoginForm");
Form validation
if (f.form.isvalid) {
F.form.submit ({
Waittitle: "Please Wait",
Waitmsg: ' Landing ... ',
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 (' Hint ', "system error ...) Please contact the administrator ");
Form.items.items[1].reset ();
}
else {
Ext.Msg.alert (' hint ', action.result.rspText);
Form.items.items[1].reset ();
}
}
});
}
},

2 binding events to the login button in initialization
Copy Code code as follows:

Class
Init:function () {
This. Loginwin.show ();
EXT.GETCMP ("Loginbtn"). On (' click ', This.loginfun);
This.loadmask = new Ext.loadmask (this. Loginwin.body, {msg: "Page load ..."});
}

3. About Ext.extend
Definition: Function extend (function sb,function Sp,object overrides)
Simple explanation: first argument--subclass
Second argument--parent class
Third argument--overriding an object
Example neutron class for XQH. ExtJs.Frame.app
The parent class Ext.util.Observable (an abstract base class) provides a common interface for the management of event mechanisms. )
For more information please see (turn) http://wangyu.javaeye.com/blog/210849
4.url: ' Http://www.jb51.net/Service/SystemService/SystemService.ashx?Method=UserLogin '
Copy Code code as follows:

public void Userlogin ()
{
StringBuilder jsondata = new Stringbuild ER ();
BOOL success = FALSE;
String rsptext = string. Empty;
if (request["LoginName"]!= null && request["LOGINPSD"]!= null)
{
String LoginName = request["Log Inname "]. 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 = "Account or password error";
}
{
Else
{
Success = false;
Rsptext = "account does not exist, please contact Administrator";
}
Jsonconvert<xuser> json = new jsonconvert<xuser> ();
Jsondata = json. Torequest (Success, Rsptext, userenity);
}
Response.Write (Jsondata);
Response.End ();
}

Note: The returned data must be JSON-formatted success,rsptext for the returned tag in JS through the action.result.success call
Come here first, next time to implement the background interface framework.

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.