Search This Blog

Showing posts with label C# Sharepoint. Show all posts
Showing posts with label C# Sharepoint. Show all posts

Tuesday, December 6, 2011

Adding a Custom Action to a SharePoint 2010 Display Form


It is common when customizing SharePoint 2010 to want to extend the user interface. Fortunately, this is easy to do by using the ribbon menu. You can add new functionality to the SharePoint 2010 ribbon as custom actions. Custom actions enable you to expand or extend the standard behavior of SharePoint 2010 core components such as using a custom action to email the details of a list item.
This topic describes two approaches for adding a custom action to a display form of SharePoint 2010 list items. The custom action is added to the ribbon as a button.
You have two options to add custom actions to a display form:
  • Adding a custom action through SharePoint 2010 features. SharePoint features enable you to easily deploy customizations. This is the preferred method when you need to package the customizations and deploy them to different servers.
  • Adding a custom action by using Microsoft SharePoint Designer 2010. SharePoint Designer helps create rapid, no-code customizations on the local server.

Custom Action Elements

 

Tuesday, October 18, 2011

Platform stack for SharePoint 2010

Platform stack for SharePoint 2010

Delete all items from a SharePoint List C# programatically

/// <summary>
/// Delete items and folders from a listFromItemTobeDeleted
/// Define WSSV3 to remove listFromItemTobeDeleted folders
/// </summary>listFromItemTobeDeleted
/// The SPList you want to
/// Delete items from
private static void DeleteAllItemfromTheList(SPList listFromItemTobeDeleted)
{
Console.WriteLine("Purging listFromItemTobeDeleted: " + listFromItemTobeDeleted.Title);
Console.WriteLine("Base Type: " + listFromItemTobeDeleted.BaseType.ToString());

// ===========================================================
// listFromItemTobeDeleted.ItemCount returns a count that includes all items
// "AND" folders.
// You can't use listFromItemTobeDeleted.Items.DeleteItemById() to remove a
// folder
// ===========================================================
System.Collections.Hashtable hashtableItemCollection =
new System.Collections.Hashtable(listFromItemTobeDeleted.ItemCount);

// ===========================================================
// SPList.Items returns all listFromItemTobeDeleted items in the entire listFromItemTobeDeleted
// regardless of folder containment
// Note, just because listFromItemTobeDeleted.ItemCount includes folders,
// listFromItemTobeDeleted.Items does not.
// ===========================================================
foreach (SPListItem listItems in listFromItemTobeDeleted.Items)
hashtableItemCollection.Add(listItems.ID,null);

// Remove the listFromItemTobeDeleted items
foreach (int ID in hashtableItemCollection.Keys)
listFromItemTobeDeleted.Items.DeleteItemById(ID);
// Clear the hashtable
hashtableItemCollection.Clear();
// ===========================================================
// SPList.Folders returns all folder items in the entire listFromItemTobeDeleted
// regardless of parent folder containment
// ===========================================================
foreach (SPListItem listItems in listFromItemTobeDeleted.Folders)
hashtableItemCollection.Add(listItems.ID,null);

// Remove the folder items
foreach (int ID in hashtableItemCollection.Keys)
{
listFromItemTobeDeleted.Folders.DeleteItemById(ID);
}
}

Featured Posts

Unlock Hidden Windows Startup and Shutdown Details : How to Enable Verbose Startup and Shutdown Messages in Windows 11

WINDOWS TROUBLESHOOTING · FULL GUIDE Unlock Hidden Windows Startup and Shutdown Details Enable Verbose Status...