Hello,
I have a form with a RadScriptManger, RadAjaxManager, and RadGrid.
One of the columns of the RadGrid loads a dynamic linkbutton that I want to pop-up an Open/Save File Dialogue box. It works without the RadAjaxManager, but with it I get this error:
Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Which is correct, I subscribe each dynamic link button to the following click event that modifies the Response,
I searched around and found this article:
http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx
Towards the bottom of that, there is this solution:
Call ScriptManager.RegisterPostBackControl() and pass in the button in question. This is the best solution for controls that are added dynamically, such as those inside a repeating template.
I didn't see "RegisterPostBackControl()" within the RadScriptManager so I added .NETs script manager and added a section in my RadGridItemDataBound procedure to add the dynamic linkbuttons to this as show below:
Which finds the LinkButtons and adds them with no errors.....However when I click the linkbutton I still get the error.
Is there any better way to get this functionality?
Either I need to figure out how to exclude the linkbuttons from the AJAX call, or a way to make the pop-up work without using the Response. Any Ideas?
Thanks,
Coty
I have a form with a RadScriptManger, RadAjaxManager, and RadGrid.
One of the columns of the RadGrid loads a dynamic linkbutton that I want to pop-up an Open/Save File Dialogue box. It works without the RadAjaxManager, but with it I get this error:
Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Which is correct, I subscribe each dynamic link button to the following click event that modifies the Response,
Protected Sub onClick(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim NewButton As LinkButton = CType(sender, LinkButton)
Dim con As New SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("NBOConnectionString").ConnectionString)
Dim cmd As New SqlClient.SqlCommand("Select Id, NDAId, FileName, [File], FileType FROM NDA_Files Where Id = " & Convert.ToInt32(NewButton.ToolTip), con)
Dim da As New SqlClient.SqlDataAdapter(cmd)
con.Open()
Dim dt As New Data.DataTable
da.Fill(dt)
For Each row As Data.DataRow In dt.Rows
With row
Dim DataFile() As Byte
DataFile = .Item("File")
HttpContext.Current.Response.Buffer = True
HttpContext.Current.Response.ContentType = .Item("FileType")
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" & .Item("FileName"))
HttpContext.Current.Response.AppendHeader("Content-Length", DataFile.Length.ToString())
HttpContext.Current.Response.BinaryWrite(DataFile)
End With
Next
Catc
I searched around and found this article:
http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx
Towards the bottom of that, there is this solution:
Call ScriptManager.RegisterPostBackControl() and pass in the button in question. This is the best solution for controls that are added dynamically, such as those inside a repeating template.
I didn't see "RegisterPostBackControl()" within the RadScriptManager so I added .NETs script manager and added a section in my RadGridItemDataBound procedure to add the dynamic linkbuttons to this as show below:
For
Each
Control
In
e.Item.Controls
If
CType
(Control, Telerik.Web.UI.GridTableCell).Controls.Count > 2
Then
If
CType
(Control, Telerik.Web.UI.GridTableCell).Controls(1).
GetType
.Name =
"LinkButton"
Then
Dim
lnkButton
As
LinkButton =
CType
(
CType
(Control, Telerik.Web.UI.GridTableCell).Controls(1), LinkButton)
ScriptManager1.RegisterPostBackControl(lnkButton)
End
If
End
If
Next
Which finds the LinkButtons and adds them with no errors.....However when I click the linkbutton I still get the error.
Is there any better way to get this functionality?
Either I need to figure out how to exclude the linkbuttons from the AJAX call, or a way to make the pop-up work without using the Response. Any Ideas?
Thanks,
Coty