After migrating from MOSS 2007 to Sharepoint 2010/2013, sometimes for some lists/libraries the libraries/list control disappears, this is a fix to adress such issues.

In MOSS 2007, sometimes we added Content Editor Web Part in Allitems.aspx, to add some text or insert some logic/customizations.
However MOSS 2007 version did not have the ribbon control which was introduced from Sharepoint 2010 onwards.
In SharePoint 2010, if you have more than one web part on a web part page, the ribbon disappears because SharePoint doesn’t know which web part to display the ribbon for, because the ribbons are obviously different for the two and SharePoint needs to know which web part to display the ribbon for.
Once you select a web part (by clicking on it) the selected web part will become “active” and the correct ribbon will show up.

To automatically set the correct ribbon,we can use javascript to point the ribbon for the lists/library.

To automatically set the correct ribbon,we can use javascript to point the ribbon for the lists/library.
Add a content editor webpart to insert the below javascript in the allitems page.
Go to Site Actions >> Edit Page and you will see a web part zone where a CEWP can be addedin the page
function SelectWP(){
//select first webpart
var wp = document.getElementById(“_wpSelected”);
if (wp != null){
wp.value =”MSOZoneCell_WebPartWPQ2″;
SelectRibbonTab(‘Ribbon.Document’, true)
ExecuteOrDelayUntilScriptLoaded(SelectWP, “sp.ribbon.js”);



What is it


It is a source analysis tool for C#. It can be used for analyzing source code as opposed to compiled assemblies which is the area for FxCop. StyleCop analyzes C# code with a set of rules to check whether the code follows the rules. It is a Microsoft tool (run from inside of Visual Studio or integrated into an MSBuild project).


Where to find


It can be downloaded from


Why to use


StyleCop is a light weight source code analysis tool which fills in the necessary gap. One of the benefits of StyleCop can be realised while conducting code reviews.


How to use


If you click on the downloads section, you will see three setups, one is the StyleCop setup which actually installs the software and the other two are CHM help files. One help file talks about the rules and the other about the API exposed by StyleCop.

Once you install StyleCop, nothing will be seen as in start menu. When you open any project of C# and right click on the project, you should see two menus in the project as shown in the figure below – one which helps us select the rules, i.e. the Stylecop settings menu and the other which runs these rules on the C# project.


If you just run the stylecop, you should see broken rules in output window as shown in the figure below:



Depending on your style or your coding standards, you will either agree or disagree with detected violations. For example in the result above I do not agree with rule SA1200 “All using directives must be placed inside of the namespace”. I have never declared my using statements inside the namespace and I do not intend to do so in future. So what can I do? I can easily modify the rule set. Let’s see how we can do this.

Right click the project and go to StyleCop Settings.

I can turn off rule SA1200 “All using directives must be placed inside of the namespace” and then if I run analysis again, my result set will not show it as a rule violation.


As you can see from screenshots above that rules are categorised into different categories such as Documentation Rules, Layout Rules, Naming Rules etc. This makes is easy work with rules in a logical way.


I have a webpart which renders a html as below:

<table width="100%" cellpadding="0" cellspacing="0" border="0">
<td id="MSOZoneCell_WebPartWPQ8" vAlign="top"><table TOPLEVEL border="0" cellpadding="0" cellspacing="0" width="100%">
<td valign="top"><div WebPartID="a0d356f1−3e14−45bf−a1f1−9f3d2a5eff00" HasPers="false" id="WebPartWPQ8" width="100%" class="ms−WPBody" allowDelete="false" style="height:425px;overflow:auto;" >

<i f rame frameBorder="0" border="0" width="100%" height="100%" overflow−x="visible" marginwidth="0" marginheight="0" marginTop="100px" scrolling="no" src="">
<div class="UserGeneric">The current browser does not support Web pages that contain the IFRAME element. To use this Web Part, you must use a browser that supports this element, such as Internet Explorer version 5 or later.</div>

I need to change the css (remove outlining border) only from that webpart without touching any other webpart on the page.
This can be done by overriding css for that particular webpart, as shown below:

border-left:none !important;
border-top:none !important;
border-right:none !important;
border-bottom:none !important;
padding-left:0px !important;
padding-top:8px !important;
padding-right:0px !important;
background-color:#ffffff !important;

My friend asked me that he was using web service to fetch data from a list/Document library consisting of 500 items, but the result fetched data only for the first page i.e 100 items.

The list I am querying has pagination, with each page showing 100 items. So, it my list has 500 items, there are 5 pages. But on using the code Lists.GetListItems method, only first 100 records(first page data) is only returned.

The code was as shown below:
Please note: here ibjview is the web reference.

string DocLibName = “Demo Doc Lib”;
XmlNode ndAllView = ibjview.GetViewCollection(DocLibName.Trim());

XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, “Query”, “”);
XmlNode ndViewFields =xmlDoc.CreateNode(XmlNodeType.Element, “ViewFields”, “”);
XmlNode ndQueryOptions = xmlDoc.CreateElement(“QueryOptions”);
ndQueryOptions.InnerXml = “-1”;
ndViewFields.InnerXml = “”;

System.Xml.XmlNode nListView= ibjlists.GetListItems(ndLists.Attributes[“ID”].Value, null, ndQuery, ndViewFields, null, ndQueryOptions, string.Empty);

The xml returned result only for the first page. He was not able to loop the code to get to the next page.
After googling, we found from msdn that,

The XML data returned by this method includes a ListItemCollectionPositionNext attribute inside the rs:Data element that contains the information to support paging.
This string contains data for the fields in the sort and for other items needed for paging.

We debugged, and found the xml was something like:
“<rs:Data ListItemCollectionPositionNext=”
      101″ Count=1000 >
   <z:row ows_FirstName=”Nancy” ows_LastName=”Name” ….. />”

So, we needed to modify the p_ID to go to the next page.
This is how, we modified our code.

XmlNode xmlPosition = nListView.SelectSingleNode(“//@ListItemCollectionPositionNext“);

XmlTextReader reader = new XmlTextReader(nListView.OuterXml, XmlNodeType.Element, null);


reader = new XmlTextReader(nodes.OuterXml, XmlNodeType.Element, null);
XmlDocument xmldoc = new XmlDocument();
 xmldoc.LoadXml(nodes.InnerXml.Replace(“z:”, “”).Replace(“rs:”, “”));
 nodelist1 = xmldoc.SelectNodes(“/data/row”);                                                                                                                                                                                                                                                                                                                          

  for (int i = 0; i < nodelist1.Count; i++)
 { foreach (XmlAttribute attr in nodelist1[i].Attributes) {/*write your code*/}}

  if (xmlPosition != null)
  ndQueryOptions.InnerXml = “<Paging ListItemCollectionPositionNext='” + xmlPosition.InnerXml + “‘ /><MeetingInstanceID>-1</MeetingInstanceID><ViewAttributes Scope=’RecursiveAll’  IncludeRootFolder=’True’ />”;            


The above code will run until xmlposition is null, which will only occur at the last page.

To find the content databases for the web application selected by WebApplicationSelector control, the code below works:

SPWebApplication webApplication = Selector.CurrentItem;
SPContentDatabaseCollection contentDBs = webApplication.ContentDatabases;
foreach (SPContentDatabase contentDB in contentDBs)

To find all content databases in the Farm, the code is given below:

SPServiceCollection services = SPFarm.Local.Services;
//foreach (SPService service in services)
if (service is SPWebService)
SPWebService webService = (SPWebService)service;
SPWebApplicationCollection webApplications = webService.WebApplications;
foreach (SPWebApplication webApplication in webApplications)
SPContentDatabaseCollection contentDBs = webApplication.ContentDatabases;
foreach (SPContentDatabase contentDB in contentDBs)

I needed to use GetListItems of web service Lists.asmx, to get all aspx pages in Pages library.
However, I saw, that I needed to pass the WebId as parameter to GetListItems. So I added another reference to SiteData.asmx.

Below, is the code to get The WebId, need to add reference to Lists.asmx here, webPath is the url of the sarepoint site.

private Guid GetWebID(string webPath)

SiteDataWebService.SiteData siteDataWS = new SiteDataWebService.SiteData();

siteDataWS.UseDefaultCredentials = true;

SiteDataWebService._sWebMetadata webMetaData;

SiteDataWebService._sWebWithTime[] arrWebWithTime;

SiteDataWebService._sListWithTime[] arrListWithTime;

SiteDataWebService._sFPUrl[] arrUrls;

string roles; string[] roleUsers; string[] roleGroups;

siteDataWS.Url = webPath + “/_vti_bin/sitedata.asmx”;

siteDataWS.Credentials = new NetworkCredential(username, password, domain);

uint i = siteDataWS.GetWeb(out webMetaData, out arrWebWithTime, out arrListWithTime, out arrUrls, out roles, out roleUsers, out roleGroups);

Guid gid = new Guid(webMetaData.WebID);

return gid;

The code to access GetListItems is shown below:

private System.Xml.XmlNode GetItems(string webPath)


ListsOnLocalhost.Lists listsWS = new Sharepoint_Unit_Tests.ListsOnLocalhost.Lists();

listsWS.Url = webPath + “/_vti_bin/lists.asmx”;

listsWS.UseDefaultCredentials = true;

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();


System.Xml.XmlNode listQuery = doc.SelectSingleNode(“//Query”);

System.Xml.XmlNode listViewFields = doc.SelectSingleNode(“//ViewFields”);

System.Xml.XmlNode listQueryOptions = doc.SelectSingleNode(“//QueryOptions”);

Guid gid = GetWebID(webPath);

System.Xml.XmlNode items = listsWS.GetListItems(listName.Text, string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions, gid.ToString());

return items;


I had VS2008,when trying to create setup project , while trying to add prerequisite of  3.5 SP1, was getting lot of errors like “The install location for prerequisites has not been set to ‘component vendor’s web site’ and the file ‘DotNetFX35SP1\dotNetFX20\aspnet.msp’ in item ‘.NET Framework 3.5 SP1’ can not be located on disk. ”

The solution of this can be found at

When I performed the steps shown in the above link,my problem was solved. Stating the steps mentioned in the link once more here,

If the .NET Framework 3.5 SP1 bootstrapper package is selected in the Prerequisite dialog box for a Setup project or in ClickOnce publishing, and also the “Download prerequisites from the same location as my application” option is selected, the following build error is shown: 

The install location for prerequisites has not been set to ‘component vendor’s web site’ and the file ‘dotNetFx35setup.exe’ in item ‘Microsoft.Net.Framework.3.5.SP1’ cannot be located on disk.

To resolve this issue:

Update the Package Data

  1. Open the [Program Files]\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 folder or %ProgramFiles(x86)%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 on x64 operating systems
  2. Edit the Product.xml file in Notepad.
  3. Paste the following into the < PackageFiles > element:
    <PackageFile Name=”TOOLS\clwireg.exe”/>
    <PackageFile Name=”TOOLS\clwireg_x64.exe”/>
    <PackageFile Name=”TOOLS\clwireg_ia64.exe”/>
  4. Find the element for < PackageFile Name=”dotNetFX30\XPSEPSC-x86-en-US.exe” and change the PublicKey value to: 3082010A0282010100A2DB0A8DCFC2C1499BCDAA3A34AD23596BDB6CBE2122B794C8EAAEBFC6D526C232118BBCDA5D2CFB36561E152BAE8F0DDD14A36E284C7F163F41AC8D40B146880DD98194AD9706D05744765CEAF1FC0EE27F74A333CB74E5EFE361A17E03B745FFD53E12D5B0CA5E0DD07BF2B7130DFC606A2885758CB7ADBC85E817B490BEF516B6625DED11DF3AEE215B8BAF8073C345E3958977609BE7AD77C1378D33142F13DB62C9AE1AA94F9867ADD420393071E08D6746E2C61CF40D5074412FE805246A216B49B092C4B239C742A56D5C184AAB8FD78E833E780A47D8A4B28423C3E2F27B66B14A74BD26414B9C6114604E30C882F3D00B707CEE554D77D2085576810203010001
  5. Find the element for < PackageFile Name=”dotNetFX30\XPSEPSC-amd64-en-US.exe” and change the PublicKey value to the same as in step 4 above
  6. Save the product.xml file


Download and Extract the Core Installation Files

  1. Navigate to the following URL:
  2. Download the dotNetFx35.exe file to your local disk.
  3. Open a Command Prompt window and change to the directory to which you downloaded dotNetFx35.exe.
  4. At the command prompt, type:
    dotNetFx35.exe /x:.
    This will extract the Framework files to a folder named “WCU” in the current directory.
  5. Copy the contents of the WCU\dotNetFramework folder and paste them in the %Program Files%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 folder (%ProgramFiles(x86)%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 on x64 operating systems). Note: Do not copy the WCU\dotNetFramework folder itself. There should be 5 folders under the WCU folder, and each of these should now appear in the DotNetFx35SP1 folder. The folder structure should resemble the following:
    o DotNetFx35SP1 (folder)

    • dotNetFX20 (folder
    • dotNetFX30 (folder)
    • dotNetFX35 (folder)
    • dotNetMSP (folder)
    • TOOLS folder)
    • en (or some other localized folder)
    • dotNetFx35setup.exe (file)

You may now delete the files and folders you downloaded and extracted in steps 2 and 4.


Get every new post delivered to your Inbox.