当整个页面的网址是不是表明按钮没有响应 [英] Buttons not responding when full page url is not showed

查看:80
本文介绍了当整个页面的网址是不是表明按钮没有响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,让说的地址是:
website.com
如果我进入网站,点击一个按钮,会弹出一个消息框,它不会工作。

如果我输入的网站是这样的:
website.com/Default.aspx

它的方式方法都显示相同的页面,但使用​​中的Default.aspx名称按钮只响应时。

我试着这样做:

 如果(!Request.Url.ToString()。包含(Default.aspx的))
        {
             的Response.Redirect(Default.aspx的);
        }

但出于某种原因,并没有帮助。这究竟是为什么,以及如何解决呢?

Buttonclick:

 保护无效btnLogin_Click(对象发件人,EventArgs的发送)
{
    尝试
    {
        Session.Clear();
        Session.RemoveAll();
        Response.Cookies.Clear();
        登录用户=新的登录(txtID.Text,txtPassword.Text);
        如果(user.IsValid)
            域名注册= user.sc;
        其他
        {
            康涅狄格州的SqlConnection =新的SqlConnection(ConfigurationManager.ConnectionStrings [hakerendbConnectionString]的ConnectionString);
            CMD的SqlCommand =新的SqlCommand(SELECT COUNT(ID)FROM tblCEO WHERE ID ='+ txtID.Text +'和密码='+ txtPassword.Text +',conn);在
            conn.Open();
            如果(cmd.ExecuteScalar()。的ToString()==1)
            {
                conn.Close();
                popupCeo.Visible = TRUE;
                返回;
            }
            其他
            {
                conn.Close();
                ajaxPanel.Alert(ת.זאוסיסמאשגויה。);
                返回;
            }
        }
    }
    抓{ajaxPanel.Alert(תקלהבמערכת,אנאחזרומאוחריותרהבעיהבטיפול。); }
    尝试
    {
        用户的HttpCookie =新的HttpCookie(用户名,Security.Encrypt(txtID.Text));
        user.Expires = DateTime.Now.AddHours(1);
        如果(chkbox.Checked)
            user.Expires = DateTime.Now.AddDays(30);
        Response.Cookies.Clear();
        Response.Cookies.Add(用户);
        开关(WHOIS查询)
        {
            案例Security.level.Investor:
                的Response.Redirect(InvestorProjectViewer.aspx);
                打破;
            案例Security.level.Agent:
                的Response.Redirect(AgentManager.aspx);
                打破;
            案例Security.level.SeniorAgent:
                的Response.Redirect(SeniorManager.aspx);
                打破;
        }
    }
    赶上{}
}


解决方案

如果它真的击中同一个页面,原因将是一些JavaScript,在的OnClientClick 事件执行 btnLogin 的处理程序。

使用任何JavaScript document.URL 将表现不同在两种情况下,作为URL会在一种情况下结束的Default.aspx,而不是在其他的。

I have a website, let say the address is: website.com if i enter the website, and click a button that should pop a message box it will not work.

if i enter the website like this: website.com/Default.aspx

which by the way both ways display the same page, but only when using the default.aspx name the buttons respond.

I tried doing this:

        if (!Request.Url.ToString().Contains("Default.aspx"))
        {
             Response.Redirect("Default.aspx");
        } 

but for some reason, did not help. Why is this happening and how do i fix it?

Buttonclick:

protected void btnLogin_Click(object sender, EventArgs e)
{
    try
    {
        Session.Clear();
        Session.RemoveAll();
        Response.Cookies.Clear();
        Login user = new Login(txtID.Text, txtPassword.Text);
        if (user.IsValid)
            whois = user.sc;
        else
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["hakerendbConnectionString"].ConnectionString);
            SqlCommand cmd = new SqlCommand("SELECT COUNT(id) FROM tblCEO WHERE id = '" + txtID.Text + "' AND password = '" + txtPassword.Text + "'", conn);
            conn.Open();
            if (cmd.ExecuteScalar().ToString() == "1")
            {
                conn.Close();
                popupCeo.Visible = true;
                return;
            }
            else
            {
                conn.Close();
                ajaxPanel.Alert("ת.ז או סיסמא שגויה.");
                return;
            }
        }
    }
    catch { ajaxPanel.Alert("תקלה במערכת, אנא חזרו מאוחר יותר הבעיה בטיפול."); }
    try
    {
        HttpCookie user = new HttpCookie("UserName", Security.Encrypt(txtID.Text));
        user.Expires = DateTime.Now.AddHours(1);
        if (chkbox.Checked)
            user.Expires = DateTime.Now.AddDays(30);
        Response.Cookies.Clear();
        Response.Cookies.Add(user);
        switch (whois)
        {
            case Security.level.Investor:
                Response.Redirect("InvestorProjectViewer.aspx");
                break;
            case Security.level.Agent:
                Response.Redirect("AgentManager.aspx");
                break;
            case Security.level.SeniorAgent:
                Response.Redirect("SeniorManager.aspx");
                break;
        }
    }
    catch { }
}

解决方案

If it's really hitting the same page, the cause will be some javascript that executes in the OnClientClick event handler of btnLogin.

Any javascript using document.URL would behave differently in your two scenarios, as the URL would end "default.aspx" in one case, but not in the other.

这篇关于当整个页面的网址是不是表明按钮没有响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆