Click here to Skip to main content
6,595,444 members and growing! (17,781 online)
Email Password   helpLost your password?
Enterprise Systems » SharePoint Server » Web Parts     Intermediate License: The Code Project Open License (CPOL)

WPSC in MOSS 2007 - "Cannot retrieve properties at this time. "

By David Meng

How does WPSC register Web Parts differing from SharePoint 2003.
C#, Office, ASP.NET, Dev
Version:2 (See All)
Posted:24 Apr 2008
Views:6,673
Bookmarked:6 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
2 votes for this article.
Popularity: 0.78 Rating: 2.60 out of 5

1
1 vote, 50.0%
2

3

4
1 vote, 50.0%
5

Introduction

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

Background

There seems not 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. But things seems not so simple because the way WPSC registers Web Parts has changed...

In WSS 2.0, WPSC registers a Web Part using tokens 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 registers a Web Part using the same tokens as WSS 2.0, but WPQ1 is used for register a null Web Part. If you try to access its properties, you will get an 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 a 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("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 that 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


Member
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
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  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: Smitha Vijayan
Copyright 2008 by David Meng
Everything else Copyright © CodeProject, 1999-2009
Web15 | Advertise on the Code Project