日期:2014-05-18  浏览次数:20443 次

Response.write()提示跳转问题
加了断点调试后台也运行Response.Write()这句话。可是运行的时候前台页面没有出现提示信息,直接跳转到softwareupgrade.aspx页面。为什么啊。我要是把Response.Redirect("softwareupgrade.aspx");这句话注释掉就会出现提示。为什么啊?
C# code

private void IBSoftwareUpgrade_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            string sql="select * from softwareupgrade where sid='"+this.txtsid.Text+"'";
            SqlConnection conn=new SqlConnection("uid=sa;pwd=sa;database=softwaremanage;server=.");
            conn.Open();
            SqlCommand cmd=new SqlCommand(sql,conn);
            SqlDataReader reader=cmd.ExecuteReader();
            if(reader.Read())
            {
                Response.Redirect("softwareupgradesearch.aspx");
            }
            else
            {
                Response.Write("<script language=javascript >confirm('此软件没有升级记录,是否添加?');</script>");
                //this.IBSoftwareUpgrade.Attributes.Add("onclick","javascript:return confirm ('此软件没有升级记录,是否添加?')");
                Response.Redirect("softwareupgrade.aspx");
            }
            reader.Close();
            conn.Close();
        }



------解决方案--------------------
Response.Write("<script language=javascript >confirm('此软件没有升级记录,是否添加?');</script>");
//this.IBSoftwareUpgrade.Attributes.Add("onclick","javascript:return confirm ('此软件没有升级记录,是否添加?')");
Response.Redirect("softwareupgrade.aspx");


=========>

Response.Write("<script>if(confirm('此软件没有升级记录,是否添加')){window.location.href='softwareupgrade.aspx';}
------解决方案--------------------
Response.Write和Response.Redirect一起用的时候就会这样,
你可以只用response.write("<script language=javascript >confirm('此软件没有升级记录,是否添加?');window.location.href='softwareupgrade.aspx'</script>");来实现
------解决方案--------------------
Response.Redirect("softwareupgrade.aspx");
======
有这句就直接过去了.

跳转可以用客户端跳转
JScript code
window.location.href='softwareupgrade.aspx'