Hi I am creating a cusotm webpart in SharePoint 2013 to display the name of all the wiki pages library on the home page so that when user click on any link it will open the wiki page.
I have done this before in SharePoint 2010 to read the list items but the same thing I am trying to do in SharePoint 2013 not able to get any result.
below if my code.
- void loadData()
- {
- SPSecurity.RunWithElevatedPrivileges(delegate()
- {
- try
- {
-
- using (SPSite site = new SPSite(SPContext.Current.Web.Url))
- {
- using (SPWeb Web = site.RootWeb)
- {
- SPList list = Web.Lists["PeopleNews"];
- SPQuery query = new SPQuery();
- query.RowLimit = 5;
- query.Query = "";
-
- SPListItemCollection items = list.GetItems(query);
- string strPR = string.Empty;
- if (items.Count > 0)
- {
- foreach (SPListItem item in items)
- {
- string strTitle = (item[linkTitle] == null ? "--" : (item[linkTitle].ToString()));
- strPR += "" + strTitle + "";
- }
- }
- PR.Text = strPR;
- }
- }
- }
- catch (Exception ex)
- {
- }
- });
I just want to show the top 5 pages link from the wiki page library on the home page.
Thanks