PANVEGA’s Blog

DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

Posts Tagged ‘Custom Actions’

How to Add Actions to the User Interface?

Posted by PANVEGA on October 10, 2007

This example shows how to add custom actions to various menus in SharePoint through a Feature.

  1. Create a UserInterfaceCustomActions folder within the setup directory at the following location: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES.
  2. Create your custom feature.xml file in visual studio
  3. Create a elements.xml file with for example some CustomActions. Define here elements for the various actions included within the feature. For the sake of example, the URL for each action points to an .aspx file and passes it a value that identifies the source of the request. <UrlAction Url=”/_layouts/CustomHello.aspx?ViewToolbar”/>
  4. Create a aspx with custom example code CustomHello.aspx with some URL Parameters Queries and some text when the users clicks on the Hypetlink in the CustomAction string clientQuery = Page.Request.QueryString[“ListId”];
  5. Copy the file into the Layouts in the 12 MOSS Directory. Better using your Solution.
  6. Create also a UserControl file with some simple input CustomHello.ascx
  7. Copy the file into the ControlTemplates in the 12 MOSS Directory
  8. At a command prompt to install the Feature in the deployment, activate the Feature on a specified subsite
  9. Then reset Microsoft Internet Information Services (IIS) so that the changes can take effect.
  10. To see the various custom actions that you have added, navigate to the following locations from the home page of a Web site in the site collection:
  • Click Site Actions to see the new action on the Site Actions menu.
  • Click Site Settings on the Site Actions menu to see a new action in the Look and Feel section of the Site Settings page.
  • Navigate to a document library and open each menu on the toolbar to see a new action on each menu.
  • In a document library that contains items, click the down arrow for an item to see the new action on the edit control block menu.
  • On the edit control block menu for an item, click View Properties and Edit Properties to see new actions on the Display form and Edit form toolbars.

here you find some Default Actions: http://msdn.microsoft.com/en-us/library/bb802730.aspx

Elements.xml

<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”&gt;
<!– 1. Document Library Toolbar New Menu Dropdown –>
<CustomAction Id=”UserInterfaceLightUp.DocLibNewToolbar”
RegistrationType=”List”
RegistrationId=”101″
GroupId=”NewMenu”
Rights=”ManagePermissions”
Location=”Microsoft.SharePoint.StandardMenu”
Sequence=”1000″
Title=”MY DOCLIB NEW MENU TOOLBAR BUTTON”>
<UrlAction Url=”/_layouts/LightupHello.aspx?NewMenu”/>
</CustomAction>

<!– 2. Document Library View Toolbar Main Link –>
<CustomAction Id=”UserInterfaceLightUp.DocViewToolbarStatic”
RegistrationType=”List”
RegistrationId=”101″
Rights=”ManagePermissions”
Location=”ViewToolbar”
Sequence=”1001″
Title=”MY STATIC VIEW TOOLBAR ITEM”>
<UrlAction Url=”/_layouts/CustomHello.aspx?ViewToolbar”/>
</CustomAction>

<!– 3. Document Library Toolbar View Toolbar Main Control –>
<CustomAction Id=”UserInterfaceLightUp.DocViewToolbarDynamic”
RegistrationType=”List”
RegistrationId=”101″
Rights=”ManagePermissions”
Location=”ViewToolbar”
Sequence=”1000″
ControlSrc=”~/_controltemplates/CustomHello.ascx“>
</CustomAction>

Read the rest of this entry »

Posted in ASP.NET, Deployment, MOSS, UserControls | Tagged: , , , , | 1 Comment »