摘要:UpdatePanel 匯出到 Excel 按鈕的問題
一般用匯出的按鈕 放在UpdatePanel 會出現這樣的錯誤

但是 只要在UpdatePanel 設定一下 把按鈕 設定成postback 就可以了


我匯出xls的程式
01
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
02
Response.Clear()
03
Response.AddHeader("content-disposition", "attachment;filename=1.xls")
04
Response.Charset = "utf-8"
05
Response.ContentType = "application/vnd.ms-excel" 'xls"
06
Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter
07
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
08
Dim strstyle As String
09
Me.GridView1.RenderControl(htmlWrite) strstyle = "<style>.xlString { mso-number-format:Text; } </style>"
10
Response.Write(strstyle)
11
Response.Write(stringWrite.ToString)
12
Response.End()
13
End Sub
14
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As System.Web.UI.Control)
15
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 02
Response.Clear() 03
Response.AddHeader("content-disposition", "attachment;filename=1.xls") 04
Response.Charset = "utf-8" 05
Response.ContentType = "application/vnd.ms-excel" 'xls" 06
Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter 07
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite) 08
Dim strstyle As String 09
Me.GridView1.RenderControl(htmlWrite) strstyle = "<style>.xlString { mso-number-format:Text; } </style>" 10
Response.Write(strstyle) 11
Response.Write(stringWrite.ToString) 12
Response.End() 13
End Sub 14
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As System.Web.UI.Control) 15
End Sub
這問題發問在藍色小鋪
http://www.blueshop.com.tw/board/show.asp?subcde=BRD20080411111304TSE&fumcde=
感謝 狐狸 的回答
Protected
Public