Showing posts with label Add custom menu actions. Show all posts
Showing posts with label Add custom menu actions. Show all posts

Tuesday, January 11, 2011

Add custom menu actions programmatically in SharePoint 2010

using (SPSite site = new SPSite("http://moss.dev.com"))
{ 
        using (SPWeb web = site.OpenWeb())
        {
            SPContentType contentType = web.ContentTypes["Curriculum Vitae"];

            SPUserCustomAction action = web.UserCustomActions.Add();
            action.RegistrationType = SPUserCustomActionRegistrationType.ContentType;
            action.RegistrationId = contentType.Id.ToString();
            action.Location = "EditControlBlock";
            action.Sequence = 450;
            action.Title = "Test";
            action.Rights = SPBasePermissions.EditListItems;
            action.Url = "http://www.google.com";

            action.Update();
        }
}