Setting RadGrid to allow Response writes breaks other telerik controls

2 posts, 0 answers
  1. Thomas
    Thomas avatar
    8 posts
    Member since:
    Aug 2013

    Posted 04 Oct 2016 Link to this post

    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.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 of course causes an error unless I register the RadGrid as a postback control in Page_Load:

            ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);


    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();
            radWin = oManager.GetWindowByName("rwReplaceTemplate");
            radWin.setSize(500, 175);
            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.

  2. Konstantin Dikov
    Konstantin Dikov avatar
    2466 posts

    Posted 07 Oct 2016 Link to this post

    Hello Thomas,

    You can enable the AJAX for RadGrid by wrapping it within a RadAjaxPanel and disabling the AJAX conditionally, as demonstrated in the following help topic:
    As you will notice, in the condition for disabling the AJAX you will only have to use the correct ID, corresponding to the button that will initiate the command.

    You could also take a look at the documentation regarding the GridAttachmentColumn:
    Hope this helps.

    Best Regards,
    Konstantin Dikov
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top