Montag, 28. Februar 2011

Problem with SPSiteDataQuery

... that SPSiteDataQuery always treats fields of type TaxonomyFieldTypeMulti as empty fields (remember that Language field is mandatory and all documents have some values in it)


http://sadomovalex.blogspot.com/2011/02/problem-with-spsitedataquery-and.html

Donnerstag, 17. Februar 2011

DisableLoopbackCheck on Error 401.1

Wenn Sie mithilfe des vollqualifizierten Domänennamens (FQDN) oder eines benutzerdefinierten Hostheaders eine lokale Website aufrufen, die auf einem Computer mit Microsoft Internet Information Services (IIS) 5.1 oder höher gehostet wird, wird möglicherweise eine Fehlermeldung etwa folgenden Inhalts angezeigt:

HTTP 401.1 - Unautorisiert: Anmeldung fehlgeschlagen


http://support.microsoft.com/kb/896861

Adding paging to SPGridView


oGrid.PageSize = 3;
oGrid.AllowPaging = true;
oGrid.PageIndexChanging += new GridViewPageEventHandler (oGrid_PageIndexChanging);
oGrid.PagerTemplate = null;
// Must be called after Controls.Add(oGrid)
   
 
http://blogs.msdn.com/powlo/archive/2007/03/23/Adding-paging-to-SPGridView-when-using-custom-data-sources.aspx

Unit testing Sharepoint


      
       
       
       

Some interesting Links

       
Roy Osherove (Der ausm Biergarten)
Homepage
           
21Apps
Homepage 
           
Richard Fennell (blackmarble)
Is Pex and Moles the answer to Sharepoint testing?
           
Channel9
Pex - Unit Testing of SharePoint Services that Rocks! ( Video, classified as unwanted by your administrator)
Video: Unittesting Sharepoint That Rocks ( Stored on S: )

           
Microsoft Research  
Pex Project
Pex and Moles - Getting Started with Pex
Unit Testing SharePoint Foundation with Microsoft Pex and Moles (PDF)


     
Downloads
PEX Academic (MSI)
TypeMock

Exception on starting Unittests


If you recieve this error during starting Unittests in Visual Studio
just open the "Team Explorer" and let VisualStudio establish a connection to TFS

Get all workflows associated with an item


SPWorkflowAssociationCollection.GetAssociationByBaseID(Guid BaseID) only returns "activated" workflows.
This means only workflows which have AutoStartCreate, AutoStartChange or AllowManual set to true will be returned.
To get all workflows associated with the item, just enumerate over the WorkflowAssociations member.

Approval of Listitems and Folders


Approving a Listittem
SPListItem item = …;
item.File.Approve("Initial Version");
 
Approving a folder
SPFolder folder = … ;
SPListItem li = folder.Item;
li.ModerationInformation.Status = SPModerationStatusType.Approved;
li.Update(); 

Using Moles with 64Bit


Add the following Directive to each Testclass 
[assembly: MolesAssemblySettings(Bitness = MolesBitness.x64)]

CSS styles used on Team Site

The following table summarizes selected top-level elements and CSS styles used on the default Team Site home page. Use this table as a starting point for understanding how to use cascading style sheets to customize SharePoint Foundation


http://msdn.microsoft.com/en-us/library/ms438349.aspx

Mittwoch, 16. Februar 2011

Do not use "MaintainScrollPositionOnPostBack = true" in WebParts

Using "this.Page.MaintainScrollPositionOnPostBack = true" will break javascript functions on the Webpage

xmlnamespace without prefix

Regarding the following XML, the XPath-Expression "//title" will only return the second title node.

The reason is the Namespace "withoutPrefix" which is defined without any Prefix, applying to all "nacked" nodes.

To retrieve the first title node, a "default" Prefix has to be added to the Namespacemanger.

Add the defined Prefix to your xPath-Expression and you 'll get the node.


<rootnode>
  <firstnode  xmlns="withoutPrefix" xmlns:inf="withPrefix">
    <title>the first title</title>
    <inf:type>nonsense</inf:type>
  </firstnode>
  <secondnode  xmlns:inf="withPrefix">
    <title>the second title</title>
    <inf:type>crap</inf:type>
  </secondnode>
</rootnode>


nsmgr.AddNamespace("default", "withoutPrefix");

string xPath = "//default:title");

Adding a ListViewWebPart to Page


[UPDATE 01.Feb.2012: wp.ViewGuid = string.Empty gilt nur für 2007]
Hier eine Erklärung für 2010
[ENDUPDATE]
[UPDATE: Set View to "Summary View"]


using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;

// Get a reference to a web and a list
SPSite site = new SPSite("http://localhost:8000");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Contacts"];

// Instantiate the web part
ListViewWebPart wp = new ListViewWebPart();
wp.ZoneID = "Left";
wp.ListName = list.ID.ToString("B").ToUpper();
// wp.ViewGuid = list.DefaultView.ID.ToString("B").ToUpper();
// Set the ViewGuid to string.Empty to get the "Summery View"
// including the "Add New Item"-Button
// Thanks to sadomovale
wp.ViewGuid = string.Empty;
// Get the web part collection
SPWebPartManager mgr = new SPWebPartManager("default.aspx", Storage.Shared);
// Add the web part
coll.Add(wp);