If somebody like the post and its helpful in your work then, add comments.

Thursday, March 11, 2010

SharePoint 2007 : Create Custom List Action entry and attach the dll to it.

Create a new SharePoint empty project. Create a hierarchy in that like below.

VISIOITPro024

Element.XMl



Code Snippet



  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  3.   <CustomAction
  4.     Id="{B08087EF-B682-4fb4-870B-A7CC3F1FDF0B}"
  5.     Title="Slide Reorder"
  6.     RegistrationType="List"
  7.     GroupId="ActionsMenu"
  8.     Location="Microsoft.SharePoint.StandardMenu"
  9.     Sequence="1000"
  10.   RegistrationId="2100"
  11.     Rights="EditListItems"
  12.     ControlAssembly="GMISlideLibraryFeature,Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"
  13.     ControlClass="GMISlideLibraryFeature.SlideReorderAction">
  14.   </CustomAction>
  15. </Elements>






Code Snippet



  1. class SlideReorderAction : WebControl
  2.     {
  3.         private MenuItemTemplate _MenuTemplate;
  4.         protected override  void OnLoad(EventArgs e)
  5.         {
  6.             EnsureChildControls();
  7.             base.OnLoad(e);
  8.         }
  9.         protected override void CreateChildControls()
  10.         {
  11.             base.CreateChildControls();
  12.             ListViewWebPart oListView = FindListView(Parent);
  13.             if (oListView == null) return;
  14.             {
  15.                 SPWeb site = SPContext.Current.Web;
  16.                 site.AllowUnsafeUpdates = true;
  17.               
  18.                 _MenuTemplate = new MenuItemTemplate
  19.                 {
  20.                     Text = "Slide Reorder",
  21.                     Description = "This feature allows Site Owners to add a Change Order menu item to the Slide Library",
  22.                     ImageUrl = "/_layouts/images/NEWITEM.GIF",
  23.                     ClientOnClickNavigateUrl = "javascript:window.location= '" + site.Url + "/_layouts/GMISlideReorder/SlideReorder.aspx?List=" + oListView.ListName + "&Source=' + window.location"
  24.                 };
  25.                 this.Controls.Add(_MenuTemplate);
  26.             }
  27.         }
  28.         private ListViewWebPart FindListView(Control oParent)
  29.         {
  30.             if (oParent is ListViewWebPart) return (ListViewWebPart)oParent;
  31.             if (oParent.Parent == null) return null;
  32.             return FindListView(oParent.Parent);
  33.         }
  34.     \




1 comment:

  1. Nice post about SharePoint.
    With the growth of companies, SharePoint is emerging at a rapid speed each day.
    Thanks.
    joykernel

    ReplyDelete