Link to home
Start Free TrialLog in
Avatar of Techsavy
Techsavy

asked on

SharePoint Development help

Hi,

we had a Custom List Context menu Item in "Actions menu" in SP 2007. and below is the class we used for that. Now if I would like to use the same code for SP 2010, then What will be my eqquivalent Code with SP Ribbon. For your Reference I am also including the Custom Action XML that we used in 2007. Basically, this code used to Create a menu item on the "Actions Menu" of either a document Library or any type of list. So, I am looking for a Button on the List Tab, that appears on all List Views for list and all Views of Document Library. When a user Clicks on that Button then the user is directed to a URL mentioned in the Code below. Let me know if it is not clear or need more info.



Custom Action XML:

<CustomAction Id="SomeCustom.Action" Location="Microsoft.SharePoint.StandardMenu" GroupId="ActionsMenu" Sequence="20" ControlAssembly="Some Key" ControlClass="Class mentioned below" />

Class Referenced in Above CustomXML

using System;

using System.Collections.Generic;

using System.Text;

using System.Web.UI;

using System.Web.UI.WebControls;

using Microsoft.SharePoint;

using Microsoft.SharePoint.WebPartPages;

using Microsoft.SharePoint.WebControls;

namespace MyNameSpace

{

public class MyClass : WebControl

{

protected override void OnLoad(EventArgs e)

{

EnsureChildControls();

base.OnLoad(e);

}

protected override void CreateChildControls()

{

ListViewWebPart listView = FindListView(Parent);

if (listView == null)

return;


MenuItemTemplate menu = new MenuItemTemplate();

menu.Title = "My Title";

menu.Text = "My Title";

menu.Description = "My Description";

menu.ImageUrl = "/_layouts/images/lg_icasax.gif";

menu.Sequence = 20;



SPWeb web = SPContext.Current.Web;



string urlFormat = "someURL";

string fullUrl = string.Format(urlFormat,

web.Url,

listView.ListName,

listView.ViewGuid,


System.Web.HttpUtility.UrlEncode(filterString)

);

menu.ClientOnClickScript = fullUrl;

Controls.Add(menu);

base.CreateChildControls();

}



}

}

Thanks in Advance,




ASKER CERTIFIED SOLUTION
Avatar of chapmanjw
chapmanjw
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial