I have a RadGrid in an update panel. I also have a RadWindowManager with several windows.
I have a column in the RadGrid that, when clicked, fires the ItemCommand event of the grid. In this event I generate a file from data in our database and send it to the browser:
byte[] s = System.Text.Encoding.ASCII.GetBytes(FileXML);
this.Response.ClearHeaders();
this.Response.Buffer = true;
this.Response.ContentType = "application/octet-stream";
this.Response.AddHeader("Content-Length", s.Length.ToString());
this.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + FileName + ".vlt\"");
this.Response.BinaryWrite(s);
Response.Flush();
Response.End();
This of course causes an error unless I register the RadGrid as a postback control in Page_Load:
ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
scriptManager.RegisterPostBackControl(rgTemplates);
However, I have another column in this same grid that, when clicked, displays a RadWindow. The code-behind in the ItemCommand event is:
if (e.CommandName == "Upload")
{
HiddenField hdnTemplateUploadID = (HiddenField)e.Item.FindControl("hdnTemplateUploadID");
string UploadID = hdnTemplateUploadID.Value;
string script = "OpenTemplateReplace('" + UploadID + "');";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ShowUploadWin", script, true);
}
which calls the javascript function:
function OpenTemplateReplace(UploadID) {
var oManager = GetRadWindowManager();
$('[id*="hdnReplaceTemplateUploadID"]').val(UploadID);
radWin = oManager.GetWindowByName("rwReplaceTemplate");
radWin.setSize(500, 175);
radWin.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close);
radWin.show();
radWin.center();
return false;
}
When the RadGrid is registered as a postback control, this fails because the oManager ends up being undefined.
I also have a RadAsyncUpload control (in the same UpdatePanel as the RadGrid) and after I click the column and get the javascript error described above, the RadAsyncUpload control is no longer shown.
Is there some workaround or something to avoid having to register the RadGrid as a postback control and still be able to send a file via the Response? I'm trying to avoid actually creating the files and just having the column be a link to the file.