先看代码;
                       
                       Page.RegisterStartupScript("","<script>alert('您的帐户被扣除了" + this.lblmoney.Text.ToString() + "元')</script>");
                       int fileupdatexiazaiID = Convert.ToInt32(Request.QueryString["id"].ToString());
                    int uid = int.Parse(Session["userid"].ToString());
                    int kejianid = fileupdatexiazaiID;
                    float fuM = float.Parse(this.lblmoney.Text.Trim());
                    int t = db.SaveInforAssinRY(uid, kejianid, fuM);
                    if (t != 1)
                    {
                        Page.RegisterStartupScript("test", "<script>alert('对不起,下载失败!')</script>");                    }
                    else
                    {
                        //下载并修改下载次数
                        string sql = "update EduWare set downloadCount=downloadCount+1 where ID=" + fileupdatexiazaiID + "";
                        int x = db.ExecuteInsert(sql);
                        if (x > 0)
                        {
                            string Pathxia = Server.MapPath("../" + Session["zuozhe"] + "/Courseware/");
                            string fileName = HttpContext.Current.Server.UrlEncode(filenames1);
                            string filePath = Pathxia + filenames1;
                            //使用TransmifFile下载文件
                            FileInfo info = new FileInfo(filePath);
                            long fileSize = info.Length;
                            Response.Clear();
                            Response.ContentType = "application/x-zip-compressed";
                            Response.AddHeader("Content-Disposition", "attachment;filename=" + filenames1);
                            //不指明Content-Length用Flush的话不会显示下载进度
                            Response.AddHeader("Content-Length", fileSize.ToString());
                            Response.TransmitFile(filePath);
                            Response.End();
                            Response.Flush();
                            Response.Close();大家看到第一行的弹出框了吗?我想让他弹出提示框后在执行下载,可为什么他不弹出框,就直接下载了! 请高手帮忙。谢谢

解决方案 »

  1.   

     Button1.Attributes.Add("OnClick", "return confirm('你确定要添加吗?')");
    用这个吧。
      

  2.   

    加上return false试试
    <script>alert('您的帐户被扣除了" + this.lblmoney.Text.ToString() + "元');return false; </script>
      

  3.   

    嘿嘿,這樣寫不行的~~有空去我的博客看看吧·~特地寫了一篇:js結合hidden控件實現,執行後臺程序彈出提示框,確認后繼續執行後臺代碼~~沒有文字,只有源碼,但願你能看懂~~
      

  4.   

    Page.RegisterStartupScript("", "<script>alert('您的帐户被扣除了" + this.lblmoney.Text.ToString() + "元';return false;)</script>"); 我加return false了,还是不行
      

  5.   

      Page.clientscript.RegisterStartupScript(""," <script>alert('您的帐户被扣除了" + this.lblmoney.Text.ToString() + "元') </script>"); 
    return;
      

  6.   

    Page.clientscript.RegisterStartupScript(""," <script>alert('您的帐户被扣除了" + this.lblmoney.Text.ToString() + "元') </script>",true);
    如果不行,把true 改false
      

  7.   


    加return; 后我的下载代码都不执行了
      

  8.   

    这一段你是放在按钮点击事件里吗?你直接在按钮上加一个 onclick="<script>alert('您的帐户被扣除了<%=this.lblmoney.Text.ToString()%>元') </script>"
      

  9.   

    我是写在onclick事件里边,再后台写的,而且时第一行。但一点下载还就时不出框!郁闷啊,在线等。跪求高手了
      

  10.   

    嗨按 LZ的意思
    用 confirm 不就得了 
      

  11.   


    后台注册的JS当然不是你想象的那样 写在下载代码上面就会先执行...
    忘记了前台的onpageload()是最后执行的了吗?下载可能有个按钮点击事件吧,或者下载页面的load事件都可以啊
    跟LS有的朋友说的那样写在click里面吧