.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Programmatically enable sorting for Navigation SharePoint

Posted By:Vijai Anand. R       Posted Date: May 14, 2011    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article we will be seeing how to enable sorting for navigation using object model in SharePoint 2010
 

I have a site collection with the SharePoint Server Publishing Infrastructure feature enabled on the site collection and sites with the SharePoint Server Publishing site feature activated.

Go to Site Actions => Site Settings => Look and Feel => Navigation => Sorting.

LookandFeel.png

Programmatically Enable/Disable Sorting for navigation



using (SPSite siteCollection = new SPSite("http://servername:1111/sites/sample"))
{
using (SPWeb web = siteCollection.RootWeb)
{
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
// Sorting
// Do sorting
publishingWeb.Update();
}
}

########################################################################################################

// Sort manually


SortManually.png


publishingWeb.Navigation.OrderingMethod =
OrderingMethod.Manual;



//Sort manually with automatic paging
SortManuallywithPagesSorted.png

publishingWeb.Navigation.OrderingMethod =
OrderingMethod.ManualWithAutomaticPageSorting;
//sort automatically

SortAutomatic.png

publishingWeb.Navigation.OrderingMethod =
OrderingMethod.Automatic;
//Sort by title
publishingWeb.Navigation.AutomaticSortingMethod =
AutomaticSortingMethod.Title;
//Sort by created date
publishingWeb.Navigation.AutomaticSortingMethod =
AutomaticSortingMethod.CreatedDate;
//Sort by last modified date
publishingWeb.Navigation.AutomaticSortingMethod =
AutomaticSortingMethod.LastModifiedDate;
//Sort by ascending order
publishingWeb.Navigation.SortAscending =
true;
//Sort by descending order
publishingWeb.Navigation.SortAscending =
false;


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend