Add Code-Executing Context Menu Option To List Item

You can create a new menu option to a SharePoint list item using a feature. The following example will add a new option to the context menu of the list items, which will also execute code behind when clicked. For a simplified, static version of this code, see this article.

feature.xml
     

elements.xml
This will only associate the new menu option to items of specific Content Type (where the '0xSomeID' equals the Content Type ID). UrlAction is the URL that will open when the user clicks the item.        

The Code-Behind
public class MyClassName : SPLinkButton {    private int itemId = -1; private Guid listId = Guid.Empty; protected override void OnLoad(EventArgs e)    { if (this.Page.Request["__EVENTTARGET"] == "MyAction") {            itemId = Convert.ToInt32(this.Page.Request["__EVENTARGUMENT"].Split('#')[0]); listId = new Guid(this.Page.Request["__EVENTARGUMENT"].Split('#')[1]); }        EnsureChildControls; base.OnLoad(e); }    protected override void CreateChildControls {        if (itemId != -1 && listId != Guid.Empty) {            SPListItem currentItem = SPContext.Current.Web.Lists[listId].Items.GetItemById(itemId); if (currentItem != null) {                // Now do what you need to do with 'currentItem' }        }         base.CreateChildControls; } }