Monday, January 16, 2006

I've just been going through the process of upgrading my development SharePoint sites to run on ASP.NET 2.0 and SQL server 2005.

First I installed the WSS Service Pack 2. No problems there.

Then I upgraded one of my sites to run on ASP.NET 2.0 using the nice new IIS property tab and running the stsadm -o upgrade -forceupgrade -url http://portalsiteurl command . The ststadm command updates the web.config in the IIS root directory and it also runs the contents of Web Server Extensions\60\TEMPLATE\SQL\STOREUP.SQL. This adds some new fields to tables and updates a lot of the core stored procedures.

An IISRESET later and I could browse to the WSS sites running on ASP.NET 2.0 with no problems.

The real problem came when I try to access another set of WSS sites that were running on a different IIS virtual server that gave me the dreaded Server Application Unavailable error

 

No panic as I knew from previous experience this is almost always a problem with Web.Config parsing or Application Pool configuration/identity .

Checking the Event Log gave me this

 

 

 

Fantastic, a helpful error message, it pointed me straight to the fact that the same Application Pool was in use by both Virtual Server applications and ASP.NET doesn't support loading a second version of .NET in the same worker process.

The fix is to create a new App Pool for the applications you want to run under ASP.NET 2.0. This would include any .Net applications that share an AppPool not just SharePoint.

 

 

Create a new App Pool based on the existing SharePoint one, give it a meaningful name

 

Assign it to the Virtual Server running SharePoint

an iisreset later and you should be good to go.

I'm so glad I don't try this stuff out on live servers, anymore.

Monday, January 16, 2006 11:43:12 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Sunday, January 15, 2006

One Click Minimize/Restore for WebParts

One anoyance I have with WebPart pages that have a lot of WebParts is the need to click the WebPart menu to select Minimize or Restore when you want a little more screen real estate or you need to expand a previously minimized WebPart.

To solve this niggle I've developed a simple WebPart that using client side Javascript that traps the double click on a WebPart title and toggles the state of the WebPart. It integrates with the SharePoint client side object model so any changes are saved to the site and persists across sessions.

Unzip the DoubleClick WebPart Minimize/Restore DWP file to a directory of your choice

Browse to the SharePoint WebPart page - Click the 'Modify My Page' - 'Add Web Parts' - 'Import menu' option

Click the Browse button and select the DWP file.

Click the upload button - once uploaded you can drag the WebPart to anywhere on the page.

 


Here's a little more detail of the SharePoint client side scripting.

First I needed to get a list of WebParts on a page. Thats easy - every WebPart page that holds WebParts has a global object WPSC that is initialized like this WPSC.Init(document). The object WPSC is defined in IE55up.js/IE50.js/NonIe.js depending on browser. This is the Web Part Page Services Component which handles the client side WebPart infrastructure, it provides services such as loading/saving properties and handles page events see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/wpscaOverview_SV01098760.asp  for more details.

OnPage javascript adds every WebPart on the page to its WebPartPage.Parts collection e.g.

WPSC.WebPartPage.Parts.Register('WPQ1','8db7d8d8-b1e0-4e9d-84ff-0b266b8c0beb',document.all.item('WebPartWPQ1'))

To get a list of all the WebParts on the Page you can do this

for(var i=0; i< WPSC.WebPartPage.Parts.Count;i++)
  {
    wp=WPSC.WebPartPage.Parts.Item(i);
}

What we really need is the WebPartQualifierproperty of the WebPart which is the unique ID for each WebPart on the Page, various parts of the WebPart are then suffixed with this identifier e.g WebPartTitleWPQ2 for the title div and WebPartWPQ2 for the actual serverside rendered HTML div container.

So to hook the DblClick event we can modify the inner loop like so

    wpq=WPSC.WebPartPage.Parts.Item(i).WebPartQualifier;
    var oTitle=document.getElementById('WebPartTitle' + wpq);
  
    if (oTitle)
    { 
       oTitle.attachEvent('ondblclick',MinRestoreWP);
    }

Here we're setting the double click event to fire the MinRestoreWP function. this is defined as

function MinRestoreWP()
{
var WPQId, WPObject;
var titleid,  WPQPos;

// Clear the selection the double click produces
document.selection.empty();
window.event.cancelBubble = true;
window.event.returnValue = false;

titleid=window.event.srcElement.parentNode.id;
WPQPos=titleid.lastIndexOf("WPQ");
if (WPQPos>0)
{
   WPQId='WebPart' + titleid.substring(WPQPos, titleid.length);
   WPObject=document.getElementById(WPQId);
   // call the MSO api to do the work
   if (WPObject) MSOLayout_MinimizeRestore(WPObject);
}
 
return false;
}

Here we get the WebPart to collapse or expand by going to the parent element of the Title bar which holds the WebPart title id which we can parse to get the WPQ id. This allows us to get the WebPart object we need.

The expand collapse is handled by a SharePoint function MSOLayout_MinimizeRestore which simply takes a WebPart object and does the hard work of hidding or showing the webpart by changing the WebPart.style.display CSS property. It also logs the change so the property is saved back to the WebPartPages webservice and is remembered if you close the browser and revisit the page.

DoubleClickWebPartMinimizeRestore.zip (1.35 KB)
Sunday, January 15, 2006 6:21:03 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [6]  | 
 Saturday, January 14, 2006

hi and welcome to my blog.

I'm Colin Byrne a SharePoint Architect at Flexnet Consultants based in Surrey UK.

When I was a kid I'd always get myself into trouble by taking apart anything I could, electrical, mechanical it didn't matter, you could follow the trail of screws to the corner where I had successfully taken apart plugs, hoovers, walkmans, irons.

Of course I could never put them back together again but as I was a kid that was someones else problem alas now I'm older its my problem if things don't work after I play with them. Unfortunately for SharePoint i've taken a severe liking to it and the old curiosity is kicking in so I'll be delving into the inner working of SharePoint but along the way hopefuly produce some free WebParts and utilites that can make users and admins life easier.

One of the things I also like to do is make SP sites a lot less static so adding Flash based WebParts with dynamic content is something I like to do. I'll be blogging about developing a SlideShow WebPart using Flash in the future, also new technologies such as AJAX and Atlas, well its not that new SharePoint already uses the XMLHTTP object to save and load WebPart properties but more of that later.

Oh have I mentioned I hate having to do the same thing twice.

 

Saturday, January 14, 2006 8:35:50 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, July 20, 2005

Be sure to visit all the options under "Configuration" in the Admin Menu Bar above. There are 16 themes to choose from, and you can also create your own.

 

Wednesday, July 20, 2005 7:00:00 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  |