0

I have created a gridView, which contains link buttons with the names. In the Code Behind file, i wrote following code for download option.

protected void gridview_RowCommand(object sender, GridViewCommandEventArgs e)

{
    if (e.CommandName == "Download")
    {
        String x = "~/Nike_folder/MSR/" + e.CommandArgument.ToString();
        string FName = Server.MapPath(x);
        Response.Clear();
        Response.ContentType = "application/*.*";
        Response.AppendHeader("Content-Disposition", "attachment; filename=" + FName);
        Response.TransmitFile(FName);
        Response.End();
    }
}

Once user click on any link, browser window will open and ask for open or save or cancel.

I would like to find out whether the user clicks on Open or save.

Is there any way to find this out?

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
Subbu
  • 37
  • 8
  • 1
    Where is your gridview code ? And what is the issue with current code ? – Mahesh Feb 24 '15 at 08:36
  • There is no issue in the code? My question is, If user clicks on the link it will open browser window and ask for open the file or save the file. So User click on open the file, i would like to get user is trying to open the file. Otherwise if he saves the file, i would like to get user saved the file. – Subbu Feb 24 '15 at 08:43
  • Ok ASFIK there is no event that can give you what you want take look here http://stackoverflow.com/questions/2343418/browser-event-when-downloaded-file-is-saved-to-disk – Mahesh Feb 24 '15 at 08:46

1 Answers1

0

supposing you have two button in your gridView

var currentButton = sender as Button;

and then currentButton.Text or any property

Med.Amine.Touil
  • 1,225
  • 2
  • 11
  • 15
  • buttons are not belongings to the gridview. Actuvally it is IE or Crome Browse window. – Subbu Feb 24 '15 at 08:46
  • so when you click the hyperlink you are invoking jqueryui dialog ? – Med.Amine.Touil Feb 24 '15 at 08:49
  • I am not calling any javascript/Jquery.Response.Clear(); Response.ContentType = "application/*.*"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + FName); Response.TransmitFile(FName); Response.End();This will take care everything. – Subbu Feb 24 '15 at 08:51
  • If you can manipulate action click in client side, you can use a hidden field as same as session or response.queryString to store which button has invoked this action. – Med.Amine.Touil Feb 24 '15 at 08:53