我点击Button先进行一些处理,然后弹出一个提示窗口,并定位到另一页,我这样为什么不行!在 Button 的onclick函数中:Response.Write("<script> alert('操作成功!'); </script>");
Response.Redirect("mypage.aspx");
上面的程序运行里并不弹出那个提示窗口!怎么回事?应该怎么写代码?

解决方案 »

  1.   

    不要用Response.Write("<script> alert('操作成功!'); </script>");
    写成
    ClientScript.RegisterStartupScript(this.GetType(), "uniquestr", "alert('操作成功!')", true);
    Response.Redirect("mypage.aspx");
      

  2.   

    Response.Write("<script> alert('操作成功!'); window.location.href='mypage.aspx'</script>");速度太快了的意思是:Response.Write("<script> alert('操作成功!'); 发送往客户端几乎在同时Response.Redirect("mypage.aspx");就执行了
      

  3.   

    都错了,不是太快的原因...alert会阻塞的,所以不存在太快,在alert的按钮没点以前是不进行下面的加载的.

    ClientScript.RegisterStartupScript(this.GetType(), "uniquestr", "alert('操作成功!')", true);
    Response.Redirect("mypage.aspx");
    也是不可以的.
    主要原因在于你的alert是要发送回客户端才起作用,而Response.Redirect使它没有机会起作用.
    用这个:
    Response.Write("<script> alert('操作成功!'); window.open('mypage.aspx','_self');</script>");
    2个都是写客户端的就没问题了.
      

  4.   

    都错了,不是太快的原因...alert会阻塞的,所以不存在太快,在alert的按钮没点以前是不进行下面的加载的.
    -----
    你跟本没机会点alert按钮,楼主代码也不会引起阻塞,很简单你试下就知道了."在alert的按钮没点以前是不进行下面的加载的."对客户端脚本而言,的确如此,可是下面的代码:
    Response.Write("<script> alert('操作成功!'); </script>");
    Response.Redirect("mypage.aspx");
    将直接重定向到mypage.aspx,而不会"阻塞"
      

  5.   

    Response.Write("<script> alert('操作成功!'); window.location.href='mypage.aspx'</script>");
    都用客户端的JS.