try
        {
            
            sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings["addressconn"].ConnectionString);
            sqlconn.Open();
            cmd = new SqlCommand("select username,userpassw from userinfo where username=@name and userpassw=@userpassw", sqlconn);
            //cmd.CommandText = "select username from userinfo where username=@name";
            cmd.Parameters.Add("@name", SqlDbType.VarChar, 20).Value = texaccount.Text.Trim();
            cmd.Parameters.Add("@userpassw", SqlDbType.VarChar, 100).Value = txt_pwd.Text.Trim();
            //cmd.Parameters["@name"].Value = txtName.Text.Trim();
            if (cmd.ExecuteScalar() == null)
                Response.Write("<script language=javascript>alert('登录失败');</script>");
            else
            {
            
                Session["username"] = texaccount.Text.Trim();
                Session["userpwd"] = txt_pwd.Text.Trim();
                Session["state"] = true;
                try
                {
                    Response.Redirect("Default.aspx",false );
                }
                catch (System.Threading.ThreadAbortException ei)
                {
                    throw;
                } 

            
            }
        }
        catch
        {
            Response.Write("<script language=javascript>alert('登录失败');</script>");
            //sqlconn.Close();        }
        finally
        {
            if (sqlconn.State == ConnectionState.Open)
                sqlconn.Close();
        }
    }
在网上查了一下,发现改了Response.Redirect("Default.aspx",false );
还是不能跳转啊,虽然是没有了异常。在线等着救命啊!!!

解决方案 »

  1.   

        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('登录失败');window.location='Default.aspx';", true);
      

  2.   

    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('登录失败');window.location='Default.aspx';", true);
      

  3.   

    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('登录失败');window.location='Default.aspx';", true);好使。
      

  4.   

    引用 4 楼 sfxdawn 的回复:
    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('登录失败');window.location='Default.aspx';", true);好使。好像都不行喔,很无语啊
      

  5.   


    ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert(\'登录失败!\');setTimeout(function(){location.href='Default.aspx'},1000); </script>");
      

  6.   

    如果不适用楼上所说的javascript方法,就打下断点看下,不能转跳肯定是因为在转跳前久发生异常了~