5,693,062 members and growing! (18,716 online)
Email Password   helpLost your password?
Enterprise Systems » SharePoint Server » Web Parts     Intermediate License: The Code Project Open License (CPOL)

WPSC in MOSS2007 - "Cannot retrieve properties at this time. "

By David Meng

How does WPSC register web part differ from SharePoint 2003.
C# (C# 1.0, C# 2.0, C# 3.0, C#), Office, ASP.NET, Dev

Posted: 24 Apr 2008
Updated: 24 Apr 2008
Views: 3,038
Bookmarked: 2 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
2 votes for this Article.
Popularity: 0.78 Rating: 2.60 out of 5
0 votes, 0.0%
1
1 vote, 50.0%
2
0 votes, 0.0%
3
0 votes, 0.0%
4
1 vote, 50.0%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Introduction

Web Part Service Component (WPSC) is a nice staff for SharePoint developers working on client side programming. It supplies SharePoint Web Parts objects combined with HTML objects for developers to practice on web part management.

Background

There seems no so much changes on the object level between SharePoint 2003 and SharePoint 2007. There is one more property in WPSC 3.0 than WPSC 2.0 called WebServerRelativeURL Property. But things seems like not so simple because the way WPSC register web part changed...

In WSS 2.0, WPSC register a web part using the token like WPQ1, WPQ2, WPQ3 ...

WPSC.Init(document);var varPartWPQ7 = WPSC.WebPartPage.Parts.Register('WPQ7',
    '6b93d728-6d3e-47cb-9917-37cfd0aff443',document.all.item('WebPartWPQ7'));
var varPartWPQ3 = WPSC.WebPartPage.Parts.Register('WPQ3',
    '32950565-92aa-4a11-92b0-9dcff1b4e956',document.all.item('WebPartWPQ3'));
var varPartWPQ2 = WPSC.WebPartPage.Parts.Register('WPQ2',
    '338c0c38-b8cb-4ea2-918e-2d5c632df2bd',document.all.item('WebPartWPQ2'));
var varPartWPQ4 = WPSC.WebPartPage.Parts.Register('WPQ4',
    '3612bf7c-595c-48fe-aaf4-87cbb89078a2',document.all.item('WebPartWPQ4'));
var varPartWPQ5 = WPSC.WebPartPage.Parts.Register('WPQ5',
    '43bf7599-0acf-41d7-b3f5-397cbc7eca6b',document.all.item('WebPartWPQ5'));
var varPartWPQ6 = WPSC.WebPartPage.Parts.Register('WPQ6',
    '4623b8c7-989f-471c-a3fa-7f53148acdcd',document.all.item('WebPartWPQ6'));
var varPartWPQ1 = WPSC.WebPartPage.Parts.Register('WPQ1',
    '056d0533-514b-42e1-8925-38bf2c5b3b07',document.all.item('WebPartWPQ1'));  

In WSS 3.0, WPSC register a web part using the same tokens as WSS2.0, but the WPQ1 is used for register a null web part. If you try to access its properties, you will get error:

"Cannot retrieve properties at this time."

var varPartWPQ4 = WPSC.WebPartPage.Parts.Register('WPQ4',
    'e2412c24-1c4f-4545-93dc-2a4e965b2032',document.all.item('WebPartWPQ4'));
var varPartWPQ5 = WPSC.WebPartPage.Parts.Register('WPQ5',
    '77cbc2a3-c770-4a7d-9024-63b78cc45ff4',document.all.item('WebPartWPQ5'));
var varPartWPQ6 = WPSC.WebPartPage.Parts.Register('WPQ6',
    'f4481df0-a93d-495d-bcb6-fa686bbd9816',document.all.item('WebPartWPQ6'));
var varPartWPQ7 = WPSC.WebPartPage.Parts.Register('WPQ7',
    '1fddcba4-7b65-40d9-972f-d6ee86a224f4',document.all.item('WebPartWPQ7'));
var varPartWPQ1 = WPSC.WebPartPage.Parts.Register('WPQ1',
    '00000000-0000-0000-0000-000000000000',document.all.item('WebPartWPQ1')); 

Let's go through one sample code which will collect the web part titles

if(typeof(WPSC) == 'undefined')
  return;
  
 if(WPSC.WebPartPage)
  PortalPartsCollection = WPSC.WebPartPage.Parts; 
 
 if(PortalPartsCollection) 
 { 
  for(var i=0; i< PortalPartsCollection.Count; i++) 
  { 
   var objWebPart = PortalPartsCollection.Item(i); 
    
   if(objWebPart.WebPartQualifier == "WPQ1")
    continue;
     
   if(objWebPart.Properties.Count() > 0)
   {  
    var webpartTitle = objWebPart.Properties.Item(
       "%22http://schemas.microsoft.com/WebPart/v2#Title%22%29.Value"">http://schemas.microsoft.com/WebPart/v2#Title").Value;
    PortalPartsTitleCollection.push(webpartTitle);
    
    var targetObject = searchTargetNode(objWebPart);    
    if(targetObject)
      targetObject.innerHTML = createArchor(webpartTitle) + targetObject.innerHTML;
   }   
  } 
 }

In the code above, we can see the web part with WebPartQualifier "WPQ1" will be ignored.

History

This is the first version.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

David Meng


I am so happy to have the opportunity to share experience each other with you. Currently I am a web developer on sharepoint solutions. In this field I have developed many web parts for Toronto based organizations. Recently I have done one portal customization and upgrade it from WSS 2.0 to WSS3.0. I like sharepoint development. It brings me to the world of the collision between cutting edge techniques and traditional ways. I am enjoying the experience to know Microsoft wisdoms.
Occupation: Web Developer
Company: MapleCity Consulting Inc.
Location: Canada Canada

Other popular SharePoint Server articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
  (Refresh) 
-- There are no messages in this forum --

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 24 Apr 2008
Editor: Sean Ewington
Copyright 2008 by David Meng
Everything else Copyright © CodeProject, 1999-2008
Web09 | Advertise on the Code Project