Solved

SharePoint Development help

Posted on 2010-08-13
1
389 Views
Last Modified: 2012-05-10
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,




0
Comment
Question by:Techsavy
1 Comment
 
LVL 21

Accepted Solution

by:
chapmanjw earned 500 total points
ID: 33598253
Here is Microsoft's tutorial on creating custom actions on the ribbon in 2010: http://msdn.microsoft.com/en-us/library/ms473643.aspx
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Last week I faced a strange issue recently, i have deployed SharePoint 2003 servers for one project and one of the requirements was to open SharePoint site from same server. when i was trying to open site from the same server i was getting authentic…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now