Posts

Showing posts from January, 2009

How to Add onLoad JavaScript event in SharePoint?

SharePoint provides a JavaScript array “_spBodyOnLoadFunctionNames”, any function to be executed onLoad needs to be added to this array e.g. _spBodyOnLoadFunctionNames.push("ExecuteMyFunctionOnLoad"); Now, why does your JavaScript function doesn’t execute if you just register it with ClientScript.RegisterStartupScript? Actually, content pages can’t execute JavaScript function on body load, reason; content pages can’t directly add a function to the body’s OnLoad event if master page contains the <body> element (which is mostly true). This array is basically a part of init.js located in “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\”. If you open the javascript file, you will notice the page onLoad event is handled by function _spBodyOnLoadWrapper, which further calls ProcessDefaultOnLoad, and this function executes all the function names added in array "_spBodyOnLoadFunctionNames". function addLoadEvent ( func )

CREATING AND DEPLOYING FEATURE IN MOSS

Image
Windows SharePoint Services 3.0 introduces an inherently portable and modular functionality known as feature, which provides a mechanism for defining site elements. A feature is a package of Windows SharePoint Services elements that can be activated for a specific scope and that helps users accomplish a particular goal or task. Features are added to a target site or site collection through a process known as feature activation. The element types that can be defined by a feature include menu commands, link commands, page templates, page instances, list definitions, list instances, event handlers, and workflows. So let’s start writing a feature. The functionality of the feature which we are going to develop is that it adds a menu item “Hello World” in the “Site Actions” menu. Clicking on the menu item “Hello World” will transfer to Google. Our goal is shown in the figure below: The first step is to understand the feature file structure. If you go to “C:\Program Files\Common Files\Microso

MOSS 2007: Site Usage Report Error

Scenario: When click on “Site Usage Reports” under “Site Administration” in “Site Settings” page, the following message displayed: Both Windows SharePoint Services Usage logging and Office SharePoint Usage Processing must be enabled to view usage reports. Please contact your administrator to ensure that these services are enabled. Resolution: You have to enable two options. Open “Central Administration” -> “Operation” and click on “Usage analysis processing” under “Logging and Reporting” and check “Enable Logging”. Then, move to “Shared Service Provider”, Click on “Usage reporting” under “Office SharePoint Usage Reporting” and check both options.

Deleting Webparts When error occured

Sometimes it is difficult to delete or edit a web part. When clicked on “Modify Shared web part” link, error page appeared “An unexpected error has occurred. ” One way to delete the web part is to go to web part maintenance page and delete it. This can be done by adding “? contents=1” to default.aspx page.