I have 2 button control. One is for download excel and another one is for a linkbutton that open new tab to another page. When I first click the download button is working fine. It able to download the excel file. But after I click the linkbutton that redirect to another page. I click the the download button again and it is not working and no excel file is download.
VB Net Code:
Protected Sub btnExcel_AllService_OnClick(ByVal sender As Object, ByVal e As System.EventArgs)
CType(sender, Control).Parent.Visible = False
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment;filename=AllServiceEndOfDay.xls")
Response.Charset = ""
EnableViewState = False
Dim stringWriter As New System.IO.StringWriter()
Dim htmlWriter As New HtmlTextWriter(stringWriter)
isCustomRendering = True
divExport.RenderControl(htmlWriter)
Dim style = "<style> td { mso-number-format:\@; } </style> "
Response.Write(style)
Response.Write(stringWriter)
Response.End()
isCustomRendering = False
EnableViewState = True
End Sub
Protected Sub LinkButton_Telco(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButtonTelco.Click
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "key", "window.open('index.aspx');", True)
End Sub