Valid for Sitecore 5.3
Render the sc:sublayout control via API and get HTML string

Sitecore versions: tested with 5.3.0. Expected to work with 5.3.x.

The Problem

Our code needs to render the <sc:sublayout> control via API and get HTML string.  

1.  The Solution

Use the code below to solve the problem:

using Sitecore.Web.UI.WebControls;
using Sitecore.Web;

      Sublayout sublayout
= new Sublayout();
      sublayout.Path
= "/layouts/Sublayout1.ascx";
      Control control
= sublayout.GetUserControl(this);
      
string html = HtmlUtil.RenderControl(control);
      Response.Write(
"<hr/>");
      Response.Write(html);

Where “this” is the Page object.