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);


Categories: Asp.net | C# | Telerik Controls

Currently I am working on a project are using ASP.NET MVC, and I need reuse some user controls with Telerik Controls,
As you know, many of those user controls for WebForm need enable ViewSate.
So I had combined both new MVC and old WebForm pages in this project.
and I had encountered and solved many issues both for integration and MVC
I write some key points here as my collections and want to share with my visitors.
Here is an article about adding MVC to regular website :link

 1. setup Route in Global.asax

public static void RegisterRoutes(RouteCollection routes)

// routes.IgnoreRoute("Classic/{resource}.aspx?{*requestUrl}"); //the ? is not allow in the route config
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}"); //All .aspx regard as webform.
routes.IgnoreRoute("{resource}.ash/{*pathInfo}"); //other type need escape
routes.IgnoreRoute("Classic/{resource}.aspx/{*pathInfo}"); //I put my webform files in classic folder


"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults

2. Make your old UserControls work

3. Fix those weird problems of Visual Studio 2008
After copy the Classes such as "BaseUserControl.cs" to MVC project, whatever how many times I clean and rebuild the project, Those classes always can't be found by other classes.
And another issue happen frequently is the Pages have using Telerik controls, always have error message 'Error Creating Control' at design time.
After some research, I found  those step will solve these issues like a magic.

   step 1. Close your Visual studio 2008 .
   step 2. Go to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ folder, delete all sub directories.
   step 3. Go to C:\Documents and Settings\yourname\Local Settings\Application Data\Microsoft\VisualStudio\9.0\ProjectAssemblies\
              Delete all sub diretories.
   step 4. Restart.

And some people said, if copy the Telerik dlls to Global assembly will fix Telerik issue.

Categories: Asp.net | MVC | Telerik Controls | VS 2008

<rad:RadGrid Skin="WebBlue" ID="RadGrid1" runat="server"
            GridLines="None" AllowPaging="True" AllowSorting="True" Width="97%" AutoGenerateColumns="False"
            EnableAJAX="true" ShowStatusBar="true" OnPreRender="RadGrid1_PreRender" OnNeedDataSource="RadGrid1_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand" OnInsertCommand="RadGrid1_InsertCommand" OnDeleteCommand="RadGrid1_DeleteCommand">
            <MasterTableView GridLines="None" Width="100%" CommandItemDisplay="Top" DataKeyNames="EmployeeID">
                    <rad:GridEditCommandColumn UniqueName="EditCommandColumn">
                    <rad:GridBoundColumn UniqueName="TitleOfCourtesy" HeaderText="TOC" DataField="TitleOfCourtesy">
                        <HeaderStyle Width="60px"></HeaderStyle>
                          <rad:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" />
                <EditFormSettings UserControlName="EmployeeDetailsCS.ascx" EditFormType="WebUserControl">
                    <EditColumn UniqueName="EditCommandColumn1">


in Usercontrol:

<asp:TextBox id=TextBox2 Text='<%# DataBinder.Eval( Container, "DataItem.FirstName") %>' runat="server" tabIndex=8>

Initial the dropdown in code behind:

  #region Web Form Designer generated code
  override protected void OnInit(EventArgs e)
   // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  /// <summary>
  ///  Required method for Designer support - do not modify
  ///  the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
   this.DataBinding += new System.EventHandler(this.EmployeeDetails_DataBinding);


protected void EmployeeDetails_DataBinding(object sender, System.EventArgs e)
            ArrayList tocs = new ArrayList(new string[] { "Dr.", "Mr.", "Mrs.", "Ms." });

            ddlTOC.DataSource = tocs;

            object tocValue = DataBinder.Eval(DataItem, "TitleOfCourtesy");

            if (tocValue == DBNull.Value)
                tocValue = "Mrs.";
            ddlTOC.SelectedIndex = tocs.IndexOf((string)tocValue);
            ddlTOC.DataSource = null;

DataBinder in System.Web.UI 



Categories: Telerik Controls