0

I have a page that has search box and the search will be triggered when the user hits enter key (I am checking this search on IsPostBack by enter key. Then when search is completed, the user is able to hit download on the link of the file displayed from the search.

The problem is when the user hits the link and go back to the search box, the enter key triggers the download file again.

How can I clear this event after the file is downloaded, so it triggers the IsPostBack again.?

NOTE: I am using Linkbutton control in a Gridview control to trigger the file download.

the code for downloading the file:

 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string[] arg = new string[2];
            if (e.CommandName == "DownloadFile")
            {
                arg = e.CommandArgument.ToString().Split(';');
                string fileName = arg[0];
                string path = arg[1];
                Response.Clear();
                Response.ContentType = "Application/octet-stream";
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(fileName));
                Response.TransmitFile(Server.MapPath(path + fileName));
                Response.End();
            }
        }
Ahmad
  • 33
  • 1
  • 5

1 Answers1

0

Problem [RESOLVED] all I had to do is set the AutoPostBack property of the textbox to true;

Ahmad
  • 33
  • 1
  • 5