When I try to export a complex page which has RadGrid Control to PDF file, it always returns an error message like
Script control '' is not a registered script control. 
Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
Parameter name: scriptControl

After trying many different ways, I finally found the right solution to exporting the page without exception: Override the "Render" method in the page or the UserControl.
The code is below:

protected override void Render(HtmlTextWriter writer)

        if (_isExport)
            StringWriter stringWriter = new StringWriter(); //System.IO namespace should be used

            HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);

            Response.Clear(); //this clears the Response of any headers or previous output
            Response.Buffer = true; //make sure that the entire output is rendered simultaneously

            ///Set content type to MS Excel sheet
            ///Use "application/msword" for MS Word doc files
            ///"application/pdf" for PDF files
            Response.AddHeader("content-disposition", "attachment;filename=ShippingSheet.doc");

            Response.Charset = "";
            Response.ContentType = "application/msword";

            ///Render the entire Page control in the HtmlTextWriter object
            ///We can render individual controls also, like a DataGrid to be
            ///exported in custom format (excel, word etc)
            // PrintableShippingSheet1.RenderControl(htmlTextWriter);


Comments are closed.