Saturday, March 10, 2012

Use response.write within AJAX Update Panel

Hi.

if you want to use Page.Responce.Write in updatepanle you must register it with ScriptManager Register method.

Regards.


you can use it like this:

ScriptManager.RegisterStartupScript(Me,Me.GetType,"key", "open('" + filename + "');", True)


Thanks You, You Have Saved My Day...


Hi,

I'm getting a similar error when trying to export a gridview to an excel spreadsheet within an updatepanel.

here is the code below ;

Protected Sub Export2Excel()

Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=TestExcel.xls")
Response.Charset = ""

'If you want the option to open the Excel file without saving than
'comment out the line below
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "application/vnd.xls"

Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)

Try
Results_GridView.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString)
Catch ex As Exception
End Try

Response.End()

End Sub

No comments:

Post a Comment