Как перезагрузить веб-страницу aspx после экспорта excel.
при экспорте данных в excel в asp.net , он работает нормально. Отображается диалоговое окно загрузки, но страница не перезагружается.
в функции export to excel после функции Response. End () оператор не работает.
как решить эту проблему..
Что я уже пробовал:
Private Sub ExporttoExcel(ByVal table As DataTable) Try Dim excel_name As String = "Call-Log-Monitor" HttpContext.Current.Response.Clear() HttpContext.Current.Response.ClearContent() HttpContext.Current.Response.ClearHeaders() HttpContext.Current.Response.Buffer = True HttpContext.Current.Response.ContentType = "application/vnd.ms-excel" ' HttpContext.Current.Response.ContentType = "text/csv" HttpContext.Current.Response.Write("<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">") HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + excel_name + "(" + System.DateTime.Now + ").xls") HttpContext.Current.Response.Charset = "utf-8" HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250") 'sets font HttpContext.Current.Response.Write("<font style='font-size:10.0pt; font-family:Calibri;'>") HttpContext.Current.Response.Write("<BR><BR><BR>") 'sets the table border, cell spacing, border color, font of the text, background, foreground, font height HttpContext.Current.Response.Write("<Table border='1' bgColor='#ffffff' " + "borderColor='#000000' cellSpacing='0' cellPadding='0' " + "style='font-size:10.0pt; font-family:Calibri; background:white;'> <TR>") 'am getting my grid's column headers Dim columnscount As Integer = GridView1.Columns.Count For j As Integer = 0 To columnscount - 1 'write in new column HttpContext.Current.Response.Write("<Td>") 'Get column headers and make it as bold in excel columns HttpContext.Current.Response.Write("") HttpContext.Current.Response.Write(GridView1.Columns(j).HeaderText.ToString()) HttpContext.Current.Response.Write("") HttpContext.Current.Response.Write("</Td>") Next HttpContext.Current.Response.Write("</TR>") For Each row As DataRow In table.Rows 'write in new row HttpContext.Current.Response.Write("<TR>") For i As Integer = 0 To table.Columns.Count - 1 HttpContext.Current.Response.Write("<Td>") HttpContext.Current.Response.Write(row(i).ToString()) HttpContext.Current.Response.Write("</Td>") Next HttpContext.Current.Response.Write("</TR>") Next HttpContext.Current.Response.Write("</Table>") HttpContext.Current.Response.Write("</font>") HttpContext.Current.Response.Flush() 'Dim location As String = HttpContext.Current.Request.Url.AbsoluteUri HttpContext.Current.Response.[End]() 'ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "", "alert('" + location + "');", True) ' Page.ClientScript.RegisterStartupScript(Me.GetType(), "Redirect", String.Format("this.document.href = '{0}'", location), True) Catch ex As Exception Finally End Try End Sub