Click here to Skip to main content
15,889,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
   {
       if (e.CommandName == "Download")
       {
           byte[] byteimg = null;
           byte[] byteimg1 = null;
           bool replica = false;
           GridViewRow gvrow = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer;
           string id = gvrow.Cells[0].Text;
           string servername = gvrow.Cells[2].Text;
           string filename = gvrow.Cells[1].Text;
           string f1=filename.Replace(' ', '_');
           string ext = Path.GetExtension(filename);
           Random rnd = new Random();
           int random = rnd.Next(0, 9);

           if (servername == "S1")
           {
               if (random == 0 || random == 6 || random == 9 || random == 3 || random == 1 || random == 7)
               {
                   ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('Server has been crashed.. ');", true); 
                   byteimg1 = db.getbytesreplica1(id);
                   replica = true;
                }
               else
               {
                   byteimg = db.getbytes1(id);
               }

           }
           else if (servername == "S2")
           {
               byteimg1 = db.getbytesreplica2(id);
               byteimg = db.getbytes2(id);

           }
           else if (servername == "S3")
           {
               byteimg1 = db.getbytesreplica3(id);
               byteimg = db.getbytes3(id);

           }
           else
           {
               byteimg1 = db.getbytesreplica4(id);
               byteimg = db.getbytes4(id);
           }

           if (ext == ".pdf")
           {
               Response.ContentType = "application/pdf";
           }

           else if (ext == ".doc" || ext == ".rtf" || ext == ".docx")
           {
               Response.ContentType = "Application/msword";
           }

           else if (ext == ".txt")
           {
               Response.ContentType = "text/Plain";
           }

           else if (ext == ".rar")
           {
               Response.ContentType = "Application/x-rar-compressed";
           }
           else if (ext == ".jpeg" || ext == ".jpg")
           {
               Response.ContentType = "image/jpeg";
               divmsg.InnerHtml = "asd";
           }

           else if (ext == ".png")
           {
               Response.ContentType = "image/png";
           }
           else
           {
               Response.ContentType = "Application/octetstream";
           }
           popup.Show();
          Response.AddHeader("Content-disposition", "attachment; filename=" + f1);
          // Response.AppendHeader("Content-disposition", filename.ToString());
           if (replica)
           {

               Response.BinaryWrite(byteimg1);
           }
           else
           {
               Response.BinaryWrite(byteimg);
           }
           Response.Flush();
           Response.End();
       }


   }


Above code of scriptmanager is not worng and not popping up the message....plz help me with that.
I have also used ModalPopupcontrol extender to show the message but it still does not shows the message......
i have put the scriptmanager in Bold..in above code
Thanks in advance..!! :)
Posted
Updated 22-Apr-14 21:38pm
v3

1 solution

well what happen in above code that when file download is complete your response will be end so you cant get such message once the file is download.
 
Share this answer
 
Comments
Pranav-BiTwiser 23-Apr-14 5:26am    
That i know and thanks for your comment.....
Do you have any other choice for that??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900