Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Editor > Render Rad Control From Code
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Render Rad Control From Code

Feed from this thread
  • johnathan avatar

    Posted on Jun 14, 2011 (permalink)

    I am working on a custom framework that doesn't allow me to use aspx pages to render controls. I am trying to find a way to render the HTML code using RenderControl, but I keep getting null reference errors. I've tried setting the directory and it doesn't work. If I attach the control to the current Page (instead of creating a new one), it renders properly. Unfortunately I cannot use that solution because as said, I don't have an aspx page to render onto; this framework uses Response.Write to generate the pages. Here is my code below:

            public string RenderRad()
            {
                StringBuilder sb = new StringBuilder();
                StringWriter tw = new StringWriter(sb);
                HtmlTextWriter hw = new HtmlTextWriter(tw);
     
                //HttpContext context = new HttpContext(new HttpRequest(string.Empty, "http://localhost:2090/default.aspx", string.Empty), new HttpResponse(null));
                HttpContext context = new HttpContext(Request, Response);
                //HttpContext.Current.Handler.ProcessRequest(context);
                //context.Handler.ProcessRequest(context);
                context.Handler = new SmartSitePage();
                Page p = new Page();
                 
     
                //Page p = (Page)HttpContext.Current.Handler;
                 
                HtmlForm f = new HtmlForm();
     
    //           re.RadControlsDir = @"C:\www\TestingRadControls\TestingRadControls\";
     
                re.ToolsFile = "~/RadControls/Editor/ToolsFile.xml";
                re.Editable = true;
     
                p.Controls.Add(f);
     
                f.Controls.Add(re);
                f.RenderControl(hw);
     
                return sb.ToString();
            }

  • Rumen Rumen admin's avatar

    Posted on Jun 17, 2011 (permalink)

    Hello Johnathan,

    RadControls for ASP.NET AJAX heavily depend on ASP.NET framework life-cycle and even if you render the HTML content of our controls, you will experience different JavaScript and Server errors in your scenario.
    We tried to find a solution but unfortunately without success. You can find attached our test.

    Kind regards,
    Rumen
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

    Attached files

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Editor > Render Rad Control From Code