| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2149 人关注过本帖
标题:登录按钮不能用
取消只看楼主 加入收藏
jasoft
Rank: 1
来 自:北京 东城
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-7-19
收藏
 问题点数:0 回复次数:4 
登录按钮不能用
我在后台写了一个方法,用作登录,方法如下

private void regScript()
    {
        StringBuilder script = new StringBuilder(300);
        script.Append("<script type='text/javascript'>");
        script.Append("function userLogin(){");
        script.Append("var _userName=document.getElementById('" + iptName.ClientID + "').value;");
        script.Append("var _password=document.getElementById('" + iptPWD.ClientID + "').value;");
        script.Append("var _test=login.userLogin(_userName+','+_password).value;");
        script.Append("if(_test!='sccuess'){");
        script.Append("alert('密码或用户名错误!');");
        script.Append("var _pnlLogin=document.getElementById('" + pnlLogin.ClientID + "');");
        script.Append("_pnlLogin.style.display='';");
        script.Append("var _pnlLogout=document.getElementById('" + pnlLogout.ClientID + "');");
        script.Append("_pnlLogout.style.display='none';}");
        script.Append("else{var _pnlLogin=document.getElementById('" + pnlLogin.ClientID + "');");
        script.Append("_pnlLogin.style.display='none';");
        script.Append("var _pnlLogout=document.getElementById('" + pnlLogout.ClientID + "');");
        script.Append("_pnlLogout.style.display='';");
        script.Append("document.getElementById('" + lblName.ClientID + "').innerText=_userName;}");
        script.Append("}");
        script.Append("function userLogout(){");
        script.Append("login.userOut();");
        script.Append("document.getElementById('" + pnlLogin.ClientID + "').style.display='';");
        script.Append("document.getElementById('" + pnlLogout.ClientID + "').style.display='none';");
        script.Append("document.getElementById('" + iptName.ClientID + "').value='';");
        script.Append("document.getElementById('" + iptPWD.ClientID + "').value='';}");
        script.Append("</script>");
        if (!this.Page.IsClientScriptBlockRegistered("client"))
        {
            this.Page.RegisterClientScriptBlock("client", script.ToString());
        }
    }

在初始时绑定:
protected void Page_Load(object sender, EventArgs e)
    {
        try
        {//用户已经登录
            userName = this.Session["userName"].ToString().Trim();
            this.pnlLogin.Style.Add("display", "none");
            this.pnlLogout.Style.Add("display", "");
            this.lblName.Text = Session["userName"].ToString();
        }
        catch { }
        Ajax.Utility.RegisterTypeForAjax(typeof(Controls_login));
        regScript();

    }

前台调用:<INPUT type="button" value="登 录" onclick="javascript:userLogin();">

可是这个登录按钮不管用,哪位大侠看出是哪里错了??
搜索更多相关主题的帖子: 按钮 登录 
2008-04-17 16:03
jasoft
Rank: 1
来 自:北京 东城
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-7-19
收藏
得分:0 
没有输入数据,就是登录按钮不可用
2008-04-17 17:26
jasoft
Rank: 1
来 自:北京 东城
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-7-19
收藏
得分:0 
点击不起作用!
就是点击那个按钮的时候没有反映!
ie左下方出现网页有错误的提示
2008-04-18 09:14
jasoft
Rank: 1
来 自:北京 东城
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-7-19
收藏
得分:0 
[bo]以下是引用 [un]hebingbing[/un] 在 2008-4-17 17:23 的发言:[/bo]

奥,找到了……
你的page_load事件中没有调用regScript()当然是不行了……
那样你的regScript()这个函数等于是白写了……


regScript()调用了的
2008-04-18 09:15
jasoft
Rank: 1
来 自:北京 东城
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-7-19
收藏
得分:0 
if (!this.Page.IsClientScriptBlockRegistered("client"))
        {
            this.Page.RegisterClientScriptBlock("client", script.ToString());
        }

同时警告这句话
警告    1    “System.Web.UI.Page.IsClientScriptBlockRegistered(string)”已过时:“The recommended alternative is ClientScript.IsClientScriptBlockRegistered(string key). http://go.    
会不会是这的原因呢??
2008-04-18 09:18
快速回复:登录按钮不能用
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012388 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved