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.