Force save to file

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

I have the following functionality in my program when someone clicks on a
link, it brings up a page with an excel doc in it. I would however, like it
to force the save file dialog all the time, not open in the browser if excel
is there. How would I force that option?

Thanks

Private Sub lnkPrintFriendly_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lnkPrintFriendly.Click

Response.Clear()

Response.Buffer = True

Response.ContentType = "application/vnd.ms-excel"

Response.Charset = ""

EnableViewState = False

Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter

Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)

ClearControls(Me.dgrHistory)

Me.dgrHistory.RenderControl(oHtmlTextWriter)

Response.Write(oStringWriter.ToString)

Response.End()

End Sub
 
Back
Top