RenderTemplate is a server control that accepts a comma-separated list of content Node Ids, which are then rendered using the associated template.

Simple example

At the top of your MasterPage, WebPage or UserControl, (or you can add it to your Web.config) include the following declaration:

<%@ Register Assembly="uComponents.Controls" Namespace="uComponents.Controls" TagPrefix="uComponents" %>

You then can use the control, like this...

<uComponents:RenderTemplate runat="server" NodeIds="1062,1066" />

The output would be the rendered HTML from the nodes 1062 and 1066 - using their associated templates.

Advanced example

OK, so the simple example is a bit too simple; now let's say that you want to use the Node Ids that you've selected from an MNTP?

Here we take advantage of macros! Create a new macro, name it whatever you like - for this example we'll call it "RenderTemplate".


In the textboxes for ".NET Custom Control" reference the assembly uComponents.Controls and type uComponents.Controls.RenderTemplate, then save the macro.

Once the macro has saved, you should see the "Browser properties" button appear, press it, you'll see a modal to save the control's properties.


Press "Save Properties".

Now you can add the macro to your template:

<umbraco:Macro runat="server" Alias="RenderTemplate" NodeIds="[#selectedNodes]" CurrentPage="1" EntriesPerPage="10" AltTemplateId="0" UseChildNodes="0" />

Video example

Control's Public Properties

Name Type Notes
CurrentPage int Gets or sets the current page for pagination/index.
DocTypeAliasesToUseAltTemplate string Gets or sets the doc-type aliases to use the altTemplate.
EntriesPerPage int Gets or sets the entries per page for pagination/index.
ExcludeDocTypesForChildNodes string Gets or sets the doc-type aliases to filter out if using UseChildNodes.
NodeIds string Gets or sets the node ids, comma-separated.
AltTemplateId int Gets or sets the alternative template id, (as an altTemplate).
UseChildNodes bool Gets or sets a value indicating whether to use child nodes from the current page ($currentPage).


How can I prevent a 'widget' page being accessed directly? (via URL)
The underlying code for the RenderTemplate control makes use of the umbraco.library.RenderTemplate() method, this in turn makes an internal request for the specified page (along with associated template). In doing this, a querystring parameter called "umbPageID" is set. Since that querystring parameter isn't generally available on 'normal' Umbraco-generated pages, we can check for that in the widget's page template:

<script runat="server">
	protected void Page_Load(object sender, EventArgs e)
		if (!Request.QueryString.AllKeys.Contains("umbPageID"))
			Response.Redirect("~/", true);

What the heck are the "DocTypeAliasesToUseAltTemplate" and "AltTemplateId" parameters for?
answer coming soon

What the heck are the "ExcludeDocTypesForChildNodes" and "UseChildNodes" parameters for?
answer coming soon

Updated assembly/namespace since v5.0
As of v5.0 the assembly and namespace for the RenderTemplate control has been moved to uComponents.Controls, please make sure to update any references and macros.

Last edited Sep 27, 2012 at 9:21 AM by leekelleher, version 14