.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Diffrent ways to deploy Custom Action menu in SharePoint 2010

Posted By:Sunil Yadav       Posted Date: February 28, 2011    Points: 100    Category: SharePoint    URL: http://www.dotnetspark.com  

This article explains the diffrent ways to deploy Custom Action menu in SharePoint 2010.
 

 Previously we need to create a custom List Definition in order to create a custom action menu for a specific whether it for Actions menu or ECB Menu. Now with SharePoint 2010 we can create custom actions for specific list in many ways.

Using SharePoint Designer 2010

Following are the steps to create custom action menu.
  1. Open SharePoint designer 2010 and open the site in which you want to make the changes.
  2. Select list and select list setting tab as shown below.
  3. Click on Custom Actions Button on ribbon and select the List Item Menu.
Or you can choose from custom action section shown below. This will create a Menu for the List Item(EditControlBlock).
  1. Enter the Name, Description and URL in create custom action window as shown below .


  1. Once done with this, click save and navigate to list in SharePoint.

Using Object Model


Client Object Model

//CUSTOM ACTIONS MENU USING SHAREPOINT CLIENT OBJECT MODE

private void CutomActionFromClientObjectModel()

{

using (Microsoft.SharePoint.Client.ClientContext datacontext = new Microsoft.SharePoint.Client.ClientContext("http://mossportal/"))

{

Microsoft.SharePoint.Client.List list = datacontext.Web.Lists.GetByTitle("Employees");

Microsoft.SharePoint.Client.UserCustomActionCollection customactioncollection = list.UserCustomActions;

Microsoft.SharePoint.Client.UserCustomAction customaction = customactioncollection.Add();

customaction.Title = "View Client Object Model";

customaction.Name = "My Attendance";

customaction.Sequence = 10;

customaction.Location = "EditControlBlock";

customaction.Url = "http://mossportal/_layouts/empatnd.aspx?ItemId={ItemId}";

customaction.Update();

datacontext.Load(list, lst => lst.UserCustomActions);

datacontext.ExecuteQuery();

}

}

Server Object Model

//CUSTOM ACTIONS MENU USING SHAREPOINT CLIENT OBJECT MODE

private void CutomActionFromServerObjectModel()

{

//CUSTOM ACTIONS MENU USING SHAREPOINT SERVER OBJECT MODE

using (SPSite site = new SPSite("http://mossportal/"))

{

using (SPWeb web = site.OpenWeb())

{

SPList list = web.Lists.TryGetList("Employees");

SPUserCustomActionCollection actioncollection = list.UserCustomActions;

SPUserCustomAction actions = actioncollection.Add();

actions.Title = "View Server Object Model Demo";

actions.Name = "My Attendance";

actions.Sequence = 10;

actions.Location = "EditControlBlock";

actions.Url = "http://mossportal/_layouts/empatnd.aspx?ItemId={ItemId}";

actions.Update();

}

}

}

Using Custom Site Definition







For More Info : http://msdn.microsoft.com/en-us/library/ms473643.aspx 

Happy SharePointing!!!!!!!!!!

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend