zoukankan      html  css  js  c++  java
  • EXTJS 简单登陆

     
        function ready()
        {
           var form1=new Ext.form.FormPanel({
             id:'loginForm',
             items:[
                    {xtype:"textfield",id:"userName",fieldLabel:"用户名",allowBlank:false,blankText:'请输入用户名!',emptyText:"请输入用户名"},
                    {xtype:"textfield",inputType:'password',id:"pwd",fieldLabel:"密码",allowBlank:false,blankText:'请输入密码!'}
                   ]
         
          
           });
          
           var win
           if(!win)
           {
             var win=new Ext.Window({
                title:"登陆",
                300,
                height:150,
                id:"loginWindow",
                modal:true,
                items:[form1],
                buttons:[
                         {xtype:"button",id:'btnSubmit',text:'登陆',handler:login},
                         {xtype:"button",inputType:'reset',id:'重置',text:'重置'}
                        ]
           });
           }
           win.show();
          
           function login()
           {
         
             var userName=Ext.getCmp("userName").getValue();
             var pwd=Ext.getCmp("pwd").getValue();

             if(Ext.util.Format.trim(userName)==""||Ext.util.Format.trim(pwd)=="")
             {
                Ext.Msg.alert("提示","用户名或密码不能为空!");
                return;
             }
             Ext.Ajax.request({
                              url:"submit.aspx",
                              method:'GET',//注意  如果有params指定参数  method没有显示制定 它用POST提交!!!
                              params:{paramType:"login",paramUserName:userName,paramPwd:pwd},
                             success:function(response,options)
                           {
                           var obj= Ext.util.JSON.decode(response.responseText);

                           //Ext.util.JSON.decode()将Json格式数据重构成对象   Ext.util.JSON.encode()反之!
                          if(obj.success)
                          {
                           Ext.Msg.alert("消息","恭喜您登陆成功!");
                          }
                       else{
                           Ext.Msg.alert("消息","用户名或密码错误!");
                       }
                    }
             })
                 Ext.onReady(ready);

    ==================submit.aspx页面==================================

    后台:

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["paramType"]=="login")
            {

    //模仿验证
                if (Request.QueryString["paramUserName"] == "zhang" && Request.QueryString["paramPwd"] == "12345")
                {
                    Response.Write("{success:true}");//返回JSON数据格式
                    Response.End();
                }
                else {
                    Response.Write("{success:false}");
                    Response.End();
                }

            }
            Response.Write("{success:false}");
        }


           
           }
       
        }

  • 相关阅读:
    8. String to Integer (atoi)
    PHP Warning: strftime(): It is not safe to rely on the system's timezone set
    Jackson 使用
    用vim去掉utf-8 BOM
    oracle 11g 从 dmp 文件中导出 sql 代码 的方法.
    git gitosis 添加项目
    Linux gcc和gdb程序调试用法 {转}
    Dos中转义符
    HTML样式链接到外部样式表
    转:财富与智慧
  • 原文地址:https://www.cnblogs.com/zhangqifeng/p/1487351.html
Copyright © 2011-2022 走看看