Umbraco .NET C# Usercontrol Permenant Redirect to Parent Node

This is the Code behind file to permanantly redirect to a parent node in Umbraco.
There is no need to have any controls on the .asxp page.

Step 1: Create a .Net User Control called: "RedirectToPARENTnode.aspx"

Step 2: Paste the code in to the code behind file (.cs):

(important bits highlighted in yellow)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco;
using umbraco.presentation.nodeFactory;

namespace MyUserControls.Usercontrols
    public partial class RedirectToPARENTnode : System.Web.UI.UserControl
        protected void Page_Load(object sender, EventArgs e)
            //MD 06/08/2012
           //get the current node
            Node currentPage = Node.GetCurrent();

           //get the parent node
            Node parentPage = currentPage.Parent;

            //redirect to parent node



Popular posts from this blog

Umbraco Razor Sort Nodes Ascending or Descending

Umbraco Razor get Querystring

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco