Click to Rate and Give Feedback

  Switch on low bandwidth view
Community Content
In this section
Statistics Annotations (0)
SubMenuTemplate Class (Microsoft.SharePoint.WebControls)

Namespace: Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Visual Basic (Declaration)
<ParseChildrenAttribute(ChildrenAsProperties:=False)> _
<DefaultPropertyAttribute("Text")> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel:=True)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class SubMenuTemplate
    Inherits Control
    Implements IPreRenderOverride
Visual Basic (Usage)
Dim instance As SubMenuTemplate
C#
[ParseChildrenAttribute(ChildrenAsProperties=false)] 
[DefaultPropertyAttribute("Text")] 
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)] 
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] 
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
public class SubMenuTemplate : Control, IPreRenderOverride
System.Object
   System.Web.UI.Control
    Microsoft.SharePoint.WebControls.SubMenuTemplate
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Does not appear in wss_minimal.      snorks   |   Edit   |   Show History

Using wss_minimal, the menu does not appear in the siteactions area as it does when setting sharepoint to full trust, and I get no error. I've applied a permission with the attributes given in this documentation but it still does not work.. Please help?

SubMenuTemplate      Reza Alirezaei - MVP   |   Edit   |   Show History

Description

Use the SubMenuTemplate class to define a common content and behavior for a submenu of a menu item. The template created using the SubMenuTemplate fills the entire section allocated to a submenu of the menu item. The SubMenuTemplate class becomes handy, when you need to display a specific control within a particular menu item's submenus. Placing a control onto the template container causes the control to be displayed within a submenu when the submenu is invoked.

Usage Scenario

It’s a common requirement that SharePoint developers use CustomActions in their features to customize out of the box SharePoint user interface. For example, you can customize the Site Actions menu by adding menus and submenus to it. The following CAML code snippet is the manifest of a feature that will add a new menu item to the Site Actions menu. This menu is having a reference to a class that acts as the code behind and in turn will render the UI element for the menu item.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> 
<CustomAction 
Id="{7352785B-694B-46B7-B92F-C2377CA68C6A}" 
Location="Microsoft.SharePoint.StandardMenu" 
GroupId="SiteActions" 
ControlAssembly="Demo" 
ControlClass="Demo.SDKBountyMenu"> 
</CustomAction> 
</Elements> 

When the feature above gets activated, an extra menu item is added to the Site Actions menu. This new menu item will contain a sub menu pointing to a dummy URL. The SDKBountyMenu class, which is the code behind for the parent menu item, inherits from the WebControl class.

By overriding the CreateChildControls method, you can create two objects of type SubMenuTemplate and MenuItemTemplate, and add them to the Controls collection. The SubMenuItemTemplate instance corresponds with a menu item that contains sub menu item which is in turn an instance of the MenuItemTemplate class. By setting the Text, Description and ImageUrl properties and other properties, you can specify how exactly the menu and its submenu should look like and behave. For example , the ClientOnClickNavigateUrl of the MenuItemTemplate class specifies the URL for the menu item itself.

Code Sample in C#

 public class SDKBountyMenu : System.Web.UI.WebControls.WebControl
{
protected override void CreateChildControls()
{
SubMenuTemplate skdBountyMenu = new SubMenuTemplate();
skdBountyMenu.Text = "SDK Bounty Program";
skdBountyMenu.Description = "A program to help SDK documentation for SharePoint APIs";
skdBountyMenu.ImageUrl = "/_layouts/images/lg_ICASCX.gif";

MenuItemTemplate dummyUrl = new MenuItemTemplate();
dummyUrl.Text = "Be part of Community";
dummyUrl.Description = "Help the community by documenting undocumented API calls.";
dummyUrl.ClientOnClickNavigateUrl = "http://msdn.microsoft.com/en-us/library/bb264594.aspx";
skdBountyMenu.Controls.Add(dummyUrl);
this.Controls.Add(skdBountyMenu);
}
}

Code Sample in VB.NET

Public Class SDKBountyMenu
Inherits System.Web.UI.WebControls.WebControl
Protected Overloads Overrides Sub CreateChildControls()
Dim skdBountyMenu As New SubMenuTemplate()
skdBountyMenu.Text = "SDK Bounty Program"
skdBountyMenu.Description = "A program to help SDK documentation for SharePoint APIs"
skdBountyMenu.ImageUrl = "/_layouts/images/lg_ICASCX.gif"

Dim dummyUrl As New MenuItemTemplate()
dummyUrl.Text = "Be part of Community"
dummyUrl.Description = "Help the community by documenting undocumented API calls."
dummyUrl.ClientOnClickNavigateUrl = "http://msdn.microsoft.com/en-us/library/bb264594.aspx"
skdBountyMenu.Controls.Add(dummyUrl)
Me.Controls.Add(skdBountyMenu)
End Sub
End Class
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker