SPSiteMapPathDesigner Class
Provides design-time support in a visual designer for the SiteMapPath control.
System.Object
System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Web.UI.Design.ControlDesigner
System.Web.UI.Design.WebControls.SiteMapPathDesigner
Microsoft.SharePoint.WebControls.SPSiteMapPathDesigner
System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Web.UI.Design.ControlDesigner
System.Web.UI.Design.WebControls.SiteMapPathDesigner
Microsoft.SharePoint.WebControls.SPSiteMapPathDesigner
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
The SPSiteMapPathDesigner class inherits from the System.Web.UI.Design.WebControls.SiteMapPathDesigner class which provides design-time support in a visual designer for the SiteMapPath control. SPSiteMapPathDesigner provides a more robust implementation of the SiteMapPathDesigner class in order to support various design time environments common with SharePoint.
SPSiteMapPathDesigner
Description
The Microsoft.SharePoint.WebControls.SPSiteMapPathDesigner class inherits from the System.Web.UI.Design.WebControls.SiteMapPathDesigner class which provides design-time support in a visual designer for the SiteMapPath control. SPSiteMapPathDesigner provides a more robust implementation of the SiteMapPathDesigner class in order to support various design time environments common with SharePoint.
As SPSiteMapPathDesigner is a design time support class, it relies primarily on the override of the ControlDesigner.GetDesignTimeHtml method. GetDesignTimeHtml returns a string that represents the HTML markup that should be rendered in the designer, however it should be noted that it does not affect the runtime environment.
While SiteMapPathDesigner and SPSiteMapPathDesigner are extremely analogous, there are notable enhancements in the SPSiteMapPathDesigner class. For example, as a default exit return the use of the inherited ControlDesigner.GetEmptyDesignTimeHtml is offered in order to supply HTML for an empty control if nothing is returned from the control Render method.
It should be noted that GetDesignTimeHtml should be familiar to SharePoint developers who are familiar with implementing the IDesignTimeHtmlProvider interface when developing WebParts in order to have designer support for WebParts, more common in SharePoint 2003. It is customary that the control render is just called, as demonstrated in the below.
C# Code Example
public override string GetDesignTimeHtml()
{
StringBuilder builder = new StringBuilder(10000);
StringWriter stringWriter = new StringWriter(builder);
HtmlTextWriter writer = new HtmlTextWriter(stringWriter);
try
{
RenderContents(writer);
return builder.ToString();
}
catch (Exception e)
{
// Exception Handling
}
}
Visual Basic .NET Code Example
Public Overloads Overrides Function GetDesignTimeHtml() As String
Dim builder As New StringBuilder(10000)
Dim stringWriter As New StringWriter(builder)
Dim writer As New HtmlTextWriter(stringWriter)
Try
RenderContents(writer)
Return builder.ToString()
' Exception Handling
Catch e As Exception
End Try
End Function
Usage Scenario
The primary usage of the SPSiteMapPathDesigner is internal as a decorator for sitemap composite controls. In custom development, the SPSiteMapPathDesigner can be used as a class designer decoration in a similiar fashion.
In the below, I am demonstrating a custom site map path control inheriting from the System.Web.UI.WebControls.CompositeControl. In order to offer designer support, the class is decorated with designer-time services support with a reference to SPSiteMapPathDesigner.
C# Code Example
[Designer("Microsoft.SharePoint.WebControls.SPSiteMapPathDesigner, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")]
public class CustomSiteMapPath : CompositeControl
{
}
Visual Basic .NET Code Example
<Designer("Microsoft.SharePoint.WebControls.SPSiteMapPathDesigner, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")> _
Public Class CustomSiteMapPath
Inherits CompositeControl
End Class
Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com
The Microsoft.SharePoint.WebControls.SPSiteMapPathDesigner class inherits from the System.Web.UI.Design.WebControls.SiteMapPathDesigner class which provides design-time support in a visual designer for the SiteMapPath control. SPSiteMapPathDesigner provides a more robust implementation of the SiteMapPathDesigner class in order to support various design time environments common with SharePoint.
As SPSiteMapPathDesigner is a design time support class, it relies primarily on the override of the ControlDesigner.GetDesignTimeHtml method. GetDesignTimeHtml returns a string that represents the HTML markup that should be rendered in the designer, however it should be noted that it does not affect the runtime environment.
While SiteMapPathDesigner and SPSiteMapPathDesigner are extremely analogous, there are notable enhancements in the SPSiteMapPathDesigner class. For example, as a default exit return the use of the inherited ControlDesigner.GetEmptyDesignTimeHtml is offered in order to supply HTML for an empty control if nothing is returned from the control Render method.
It should be noted that GetDesignTimeHtml should be familiar to SharePoint developers who are familiar with implementing the IDesignTimeHtmlProvider interface when developing WebParts in order to have designer support for WebParts, more common in SharePoint 2003. It is customary that the control render is just called, as demonstrated in the below.
C# Code Example
public override string GetDesignTimeHtml()
{
StringBuilder builder = new StringBuilder(10000);
StringWriter stringWriter = new StringWriter(builder);
HtmlTextWriter writer = new HtmlTextWriter(stringWriter);
try
{
RenderContents(writer);
return builder.ToString();
}
catch (Exception e)
{
// Exception Handling
}
}
Visual Basic .NET Code Example
Public Overloads Overrides Function GetDesignTimeHtml() As String
Dim builder As New StringBuilder(10000)
Dim stringWriter As New StringWriter(builder)
Dim writer As New HtmlTextWriter(stringWriter)
Try
RenderContents(writer)
Return builder.ToString()
' Exception Handling
Catch e As Exception
End Try
End Function
Usage Scenario
The primary usage of the SPSiteMapPathDesigner is internal as a decorator for sitemap composite controls. In custom development, the SPSiteMapPathDesigner can be used as a class designer decoration in a similiar fashion.
In the below, I am demonstrating a custom site map path control inheriting from the System.Web.UI.WebControls.CompositeControl. In order to offer designer support, the class is decorated with designer-time services support with a reference to SPSiteMapPathDesigner.
C# Code Example
[Designer("Microsoft.SharePoint.WebControls.SPSiteMapPathDesigner, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")]
public class CustomSiteMapPath : CompositeControl
{
}
Visual Basic .NET Code Example
<Designer("Microsoft.SharePoint.WebControls.SPSiteMapPathDesigner, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")> _
Public Class CustomSiteMapPath
Inherits CompositeControl
End Class
Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com
- 6/3/2010
- Adam Buenz - MVP