• 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}");
        }


           
           }
       
        }

  • 相关阅读:
    cf D. Vessels
    cf C. Hamburgers
    zoj 3758 Singles' Day
    zoj 3777 Problem Arrangement
    zoj 3778 Talented Chef
    hdu 5087 Revenge of LIS II
    zoj 3785 What day is that day?
    zoj 3787 Access System
    判断给定图是否存在合法拓扑排序
    树-堆结构练习——合并果子之哈夫曼树
  • 原文地址:https://www.cnblogs.com/zhangqifeng/p/1487351.html
Copyright © 2020-2023  润新知