登录代码:
JS://1.我们首先创建一个全局变量
    //2.我们在创建一个XmlHttpRequest对象
var xmlHttp;    
    function createXmlHttpRequest()
    {
        if(window.XMLHttpRequest)
        {
            xmlHttp=new XMLHttpRequest();
        
            if(xmlHttp.overrideMimeType)
                {
                    xmlHttp.overrideMimeType("text/xml");
                }
        }
        else if(window.ActiveXObject)
        {
            try
            {
                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");   
            }
            catch(e)
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");   
            }
        }
        if(!xmlHttp)
        {
            window.alert("你的浏览器不支持创建XMLhttpRequest对象");
        }
        return xmlHttp;
    }
        function ReBtn()
    {        window.location.reload();
    }
    
    function ValidateCode()
    {
        createXmlHttpRequest();
       
        var url="URL/ValidateCode.aspx?Code="+document.getElementById("TxtCode").value;
       
        xmlHttp.open("GET",url,true);
        
        xmlHttp.onreadystatechange=ValidateResult;
        
        xmlHttp.send(null);
    }
    
    function ValidateResult()
    {
        if(xmlHttp.readyState==4)
        {
            if(xmlHttp.status==200)
            { 
                if(xmlHttp.responseText=="YES")
                {
                   check();           
                }
                else
                {
                    window.alert("验证码输入错误");
                    window.location.reload();
                }
            }
        }
    }
    
    function check()
    {
        var userName=document.getElementById("TxtName").value;
        var userPwd = document.getElementById("TxtPwd").value;
        Login;
        if(Login.isRight(userName+"",userPwd+"").value>0)
        {
            //判断用户状态是否可用
            if(Login.userState(userName+"").value==0)
            {
                 //得到用户权限类型
                Login.UserType(userName+"");
                //写入Session
                Login.WriteSession(userName+"");
                window.location.href='Index.aspx';
            }
            else
            {
                alert("对不起您的帐号己禁用");
            }          
        }
        else
        {
            alert("用户名或密码不正确!");  
        }
        
      }
页面里的登录代码是:
 <input id="Login" type="button" value="登  陆"  onclick=" ValidateCode();" style="width: 75px" class="btn"/>我的问题的:
在IE8里js代码里的错误是:“ Login未定义”
这是什么原因啊
谢谢各位啊。急啊

解决方案 »

  1.   

    Login; 这段代码呢我怎么没看到你定义Login这个对象呢
      

  2.   

    要怎么去定义Login这个对象啊
    谢谢
      

  3.   

    把你的aspx代码发来看看
    Login控件?
      

  4.   

    这是Login.aspx 里的代码
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>OA管理系统--登 陆</title>
         <link href="CSS/css.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="JS/Login.js"></script>
    </head>
    <body style=" text-align:center">
       <form action="" runat="server">
        <div style="text-align: center; background-image:url(Images/Login.gif);width:435px;height:283px;position: relative; top: 143px">
            <div style="left: 30px; width: 328px; position: relative; top: 133px; height: 134px">
                <div style="width: 322px; height: 25px; text-align: left">
                    <span style="font-size: 10pt"> <span>帐 &nbsp;号:</span></span><input
                        id="TxtName" style="width: 190px" type="text" /></div>
                <div style="width: 322px; height: 25px; text-align: left">
                    <span style="font-size: 10pt"><span>密 &nbsp;码:</span></span><input
                        id="TxtPwd" style="width: 190px" type="text" /></div>
                <div style="width: 322px; height: 25px; text-align: left">
                    <span style="font-size: 11pt"> <span style="font-size: 10pt">验证码:</span></span><input id="TxtCode"
                        style="width: 71px; height: 15px;" type="text" />&nbsp;<asp:Image ID="Image1" runat="server"
                            Height="20px" ImageUrl="~/URL/Image.aspx" Style="left: 0px; position: relative; top: 3px"
                            Width="57px" />
                    <input id="Eyes" style="width: 44px; height: 21px" type="button" onclick="ReBtn();" value="看不清" class="btn" /></div>
                <div style="width: 320px; height: 35px">
                </div>
                <div style="width: 320px; height: 33px; text-align: left;">
                    &nbsp; 
                    <input id="Login" type="button" value="登  陆"  onclick=" ValidateCode();" style="width: 75px" class="btn"/>
                    &nbsp; &nbsp;&nbsp; &nbsp; 
                    <input id="Reset" style="width: 75px" type="reset" value="重  置" class="btn" /></div>
            </div>
            
        </div>
       </form>
    </body>
    </html>Login.aspx.cs:using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using BLL;
    using Model;public partial class Login : System.Web.UI.Page
    {
        UserInfoBLL ubll = new UserInfoBLL();    protected void Page_Load(object sender, EventArgs e)
        {
            //注册ajax
            if(!Page.IsPostBack)
            {
             AjaxPro.Utility.RegisterTypeForAjax(typeof(Login));
            }
           
        }    //判断用户名密码是否正确
        [AjaxPro.AjaxMethod]
        public int isRight(string userName, string userPwd)
        {
            int count = 0;
            UserInfoBean u = new UserInfoBean();
            u.userid = userName;
            u.userPwd= userPwd;
            try
            {
                count = ubll.userIsRight(u);
                
            }
            catch (Exception)
            {            throw;
            }
            return count;
        }    //判断用户类型
        [AjaxPro.AjaxMethod]
        public void UserType(string userID)
        {
            int roletype = ubll.getRoleTypeInfo(userID);
            int id = ubll.getIdByUserid(userID);
            Number.loginid = id.ToString();
            if(roletype==1)
            {   //服务员
                Number.userid="100";
            }
            else if(roletype==2)
            {   //管理员
                Number.userid = "1";
            }
            else if(roletype==3)
            {   //客人
                Number.userid = "1000";
            }
        } 
        //写入Session值
        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public void WriteSession(string userID)
        {
            Session["Login"]=userID;
        }    //判断用户状态
        [AjaxPro.AjaxMethod]
        public int userState(string userID)
        {
            try
            {
                int count = ubll.userStates(userID);
                return count;
            }
            catch (Exception)
            {
                
                throw;
            }
           
        }
    }
      

  5.   

    果然是注册的ajax呵呵 你的方法没有问题了
    可能就是Login那里的问题
    把Login;这句去掉看看
      

  6.   

    function check() {
    var userName = document.getElementById("TxtName").value;
    var userPwd = document.getElementById("TxtPwd").value;
    Login; if (Login.isRight(userName + "", userPwd + "").value > 0) {
    这里应该是用:
    Login();
    或者
    var login=new Login();
    吧。
    要看Login的情况。但不管怎样,就一个“Login;”的话,应该是不对的。
      

  7.   

    Login;
      if(Login.isRight(userName+"",userPwd+"").value>0)
      {
      //判断用户状态是否可用
      if(Login.userState(userName+"").value==0)
      {
      //得到用户权限类型
      Login.UserType(userName+"");
      //写入Session
      Login.WriteSession(userName+"");这几句话是不是搞错了啊,楼主是不是把客户端和服务器端的代码搞混了?
      

  8.   

    function check()
        {
            var userName=document.getElementById("TxtName").value;
            var userPwd = document.getElementById("TxtPwd").value;
            var  login=new Login();
            if (login.isRight(userName + "", userPwd + "").value > 0)
            {
                //判断用户状态是否可用
                if (login.userState(userName + "").value == 0)
                {
                     //得到用户权限类型
                    login.UserType(userName + "");
                    //写入Session
                    login.WriteSession(userName + "");
                    window.location.href='Index.aspx';
                }
                else
                {
                    alert("对不起您的帐号己禁用");
                }          
            }
            else
            {
                alert("用户名或密码不正确!");  
            }
            
          }我这样写还是出现错误:“Login未定义”
      

  9.   

    楼主是怎么想的呢?为什么用了ajaxPro 还自己写createXmlHttpRequest()!!!你了解过ajaxPro 的原理吗?你用firebug 可以看到他会生成4段 ashx 为后缀的js 文件!他会生成后台你page 对应的 类的js 对象!你自己页面另存为就可以看到!或者用 vs + IE 或者 firebug 调试一下var login=new Login(); 这样写,更错!