Adding JavaScript to Execute on SharePoint Page’s Body Onload Event

The SharePoint master page contains the <body> element.

SharePoint provides the “_spBodyOnLoadFunctionNames” array.

When the SharePoint page’s body is loaded, the onload event handler executes each function whose name is contained in this array.

You can add “ MyFunctionName” to the array and it will run when the body’s onload event fires.

<script language="javascript">
function MyFunctionName()
 // Code

Programmatically Add Links to SharePoint My Links

The first step is to get a reference to the UserProfileManager.

using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;

You’ll need to pass in a reference to the current SSP by using ServerContext.Current.

After that you get the current user’s profile. Passing true, will create the user’s profile if it doesn’t exist.

The QuickLinkManager class provides what we need to add, remove, or iterate through the links the user currently has.

Once we have a reference to the manager, a call to the Create method is all we need. It takes a few parameters.

The first parameter is the title followed by the URL.

The third and fourth parameters, can be used to specify a built-in group (using the QuickLinkGroupType.General enum) or by specifying a string in the next parameter to create a new one.

Finally, the last parameter, specifies the privacy settings of the link. For the purpose of the My Links menu, you would usually choose Privacy.Private. However, you can specify other settings as well for sharing the users links on their My Sites page.

UserProfileManager userProfileManager = new UserProfileManager(ServerContext.Current);
UserProfile currentUser = userProfileManager.GetUserProfile(true);
QuickLinkManager quickLinkManager = currentUser.QuickLinks;
quickLinkManager.Create("My Quick Link", "", QuickLinkGroupType.General, null, Privacy.Private);
Getting a list of My Links
foreach (QuickLink quickLink in quickLinkManager.GetItems())

Source: Corey Roth

Add AJAX to a SharePoint Master Page – The Short Version

You’ll want to have .Net Framework 3.5 installed on the SharePoint server (framework 4 doesn’t agree with SharePoint 2007).

Above the HTML tag add:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

The BODY tag should have this onload attribute:

<BODY class="body2" scroll="yes" onload="javascript:if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();">

The FORM tag should have this onsubmit attribute:

<form runat="server" onsubmit="return _spFormOnSubmitWrapper();">

Add the ToolKitScriptManager below the WebPartPages:SPWebPartManager tag:

<ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server"/>

You will see “Error Rendering Control – ScriptManager1 Could not load file or assembly ‘AjaxControlToolkit’ or one of its dependencies” but you can ignore it.

Move a SharePoint 2007 Site

This example moves a SharePoint 2007 application into a subcollection but can be used to move a site anywhere.

stsadm -o export -url http://mysharepointsite -filename z:\mysharepointsite.cmp -includeusersecurity -nofilecompression

-nofilecompression will allow you to write directly to the tartget drive without having to cache the export to the environmentvariables temp folder which is a problem if you’re running out of space on the machine you’re moving from.

2: Create a blank site at:


3: Then overwrite it using an import of mysharepointsite.cmp

stsadm -o import -url http://myportalsite/sites/mysharepointsite -filename mysharepointsite.cmp -includeusersecurity 

SQL Command to List In-Use SharePoint Databases

First, find the name of the SharePoint Config Database in the registry if you don’t already know it:

“HKLM\Software\Microsoft\Shared Tools\Web Server Extensions\12.0\Secure\ConfigDb”

Then in SQL Server Management Studio run this query:

SELECT o.[Name] AS 'DatabaseName',<br />
    Instance.[Name] AS 'DatabaseInstance',<br />
    [Server].[Name] AS 'DatabaseServer'<br />
FROM [SharePoint_Config_DB].[dbo].[Objects] AS o<br />
    INNER JOIN [SharePoint_Config_DB].[dbo].[Classes] c on = o.classid<br />
    LEFT JOIN [SharePoint_Config_DB].[dbo].[Objects] AS Instance ON o.ParentId = Instance.Id<br />
    LEFT JOIN [SharePoint_Config_DB].[dbo].[Objects] AS [Server] ON Instance.ParentId = [Server].Id<br />
    WHERE c.Fullname LIKE '%Administration.SPConfigurationDatabase%'<br />
    OR c.Fullname LIKE '%Administration.SPContentDatabase%'<br />
    OR c.Fullname LIKE '%Administration.SharedDatabase%'<br />
    OR c.Fullname LIKE '%Administration.SearchSharedDatabase%'<br />

Some of My Better Website Designs

Catching you up on some of my better website designs.

2010 SharePoint Portal Branding

2009 SurrealBox.Net website

2009 Chris.Fleischhacker.US Website

2009 MaconSys.Com Website

2008 CISF Asset Management ASP.Net Application

2008 CISF ASP.Net Portal and Details

2008 CISF Portal Alternate Theme

2005 El Paso County Human Resources Intranet Site

2005 MigNet.Com Website

2003 Pikes Peak Rose Society design on Rainbow Portal CMS.