Download file without popup in ASP.NET


I am downloading a file using the code

btnDownloadTemplate.Attributes.Add( "onClick", "'StudyReport/WordReportTemplate.doc', 'OpenTemplate', 'resizable=no,scrollbars=no,toolbar=no,directories=no,status=no,menubar=no,copyhistory=no');return false;" );

This will show a popup and the download dialog is shown. How can I avoid the popup and only the download dialog is on the screen?

Best Solution

I got the answer. I remove the Attributes and add the click event and in it.

    string path = Server.MapPath("");
    path = path + @"\StudyReport\WordReportTemplate.doc";
    string name = Path.GetFileName( path );
    Response.AppendHeader( "content-disposition", "attachment; filename=" + name );
    Response.ContentType = "Application/msword";
    Response.WriteFile( path );