Search This Blog

Sunday, August 15, 2010

Error message not shown even after setting CustomErrors in web.config

We know that if we want to see the details of error message, we can change the
<customErrors mode="On" />  to Off and we can see the exact error message.

But wait - ever after changing this to Off in web.config file - it still shows this page below:

Well the solution is to edit the web.config file in this location with <customErrors mode="Off" />  i.e.

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS

After changing the web.config, refresh the page and you will see the specific error message.

Wednesday, June 16, 2010

Visually stunning Map with color highlights in SharePoint

Lot of large organizations have offices around the world. Displaying those on map is visually appealing as well as allow users to interact with the map by clicking or hovering on a given region/country.
Examples: Display the sales figure, Display the Regional Heads / office addresses when a location is clicked on the map. Further more Data Form web part (aka Data View web part) can be configured on the same page to take input from the QueryString. The value for these QueryString Parameters can be configured on the Map (as shown in the example here).

Next Step:  Just put this code in a Content Editor Web Part and see instant results.

Here is how it looks:

Visual feedback when mouse is over a region/country

Please let me know your feedback.

<script type='text/javascript' src=''></script>

<script type='text/javascript'>

// Mohan Taneja, SharePoint Architect, STR Tech, LLC

google.load('visualization', '1', {'packages': ['geomap']});


function drawMap() {

var data = new google.visualization.DataTable();

data.addRows(3); // This is the total number of Regions Added below.

data.addColumn('string', 'Country'); // This is the code for the Country to display on the Map

// Could be any numeric value. Ideally I wanted to supress displaying this in tooltip but did not find any option.

data.addColumn('number', 'Location #');

data.addColumn('string','Comment'); // This becomes the Header for the ToolTip. Optional column


Parameter description for setValue method below.

a) The first parameter denotes the Item number or simply put the record number. Since the array start from index 0, record number 1

is index 0, Record number 2 is index 1 and so on.

b) The second parameter is the column number. Since we configured 3 columns above in data.addColumn for each region/country

there are 3 rows i.e. one for each column i.e. 0, 1, 2

c) The third parameter are the value for different columns. Example: US, 1, 'Unites States of America'

Purpose of the Value column (in our example: the "Location #" column)


The second Row for each country below is value of data type number. This is actually for range distribution and visualization of

values with different colors(shown as Data Value below). This value is important because it determines the color coding for different countries.

Examples: Population for countries, Sales for offices of a Multinational company. However if you do not have any specific data to

display you could use the method as I have done for this example i.e. pick up numbers from 0 to max number of region displayed.

The starting value of the range determines the first color from the options['colors'] setting below and

the final value determines the last color used. Example: We are using the values from 0 to 2. Hence 0 would correspond to

0xAE84F4, 1 would correspond to 0x84F491 and 2 would correspond to 0xF4DB84 in options['colors'] below. If there are more value ranges

say 0 to 10 then the code behind the scenes automatically determines the range of colors from first to last value for 3 color

specified in options.

c) The third parameter is optional and would show as header for the ToolTip when mouse is moved over the region.


// Country 1

data.setValue(0, 0, 'US');

data.setValue(0, 1, 1); // Data Value

data.setValue(0, 2, 'Head Quarter - USA');

// Country 2

data.setValue(1, 0, 'CA');

data.setValue(1, 1, 2); // Data Value

data.setValue(1, 2, 'Canada');

// Country 3

data.setValue(2, 0, 'IN');

data.setValue(2, 1, 3); // Data Value

data.setValue(2, 2, 'India');

var options = {};

options['dataMode'] = 'regions'; // There are 2 modes. We are using regions

options['colors'] = [0xAE84F4, 0x84F491, 0xF4DB84]

options['showLegend'] = false; // This shows a Static Legend for value distribution with different colors.

var container = document.getElementById('map_canvas'); // This is the div control in which the Map will be displayed

var geomap = new google.visualization.GeoMap(container); , 'regionClick', OnRegionClicked); // Attach on on click handler for Region clicked

geomap.draw(data, options); // Draws the Map


// This is the function invoked when a specific location is clicked.

function OnRegionClicked(obj)


var region = obj.region; // gets the value of the region / Country selected. Example: US

var location = window.parent.location; // Get reference to parent window i.e. window which contains our web part.

var url = location.protocol + "//" + location.hostname + ":" + location.port + location.pathname + "?"; // Create the URL for SharePoint site



case 'US': // Based on region clicked, Send parameters to QueryString

url += "location=USA";


case 'CA':

url += "location=CAN";


case 'IN':

url += "location=IND";



location.replace(url); // Redirect to this URL



<div id='map_canvas'></div>

Tuesday, June 1, 2010

Deploy custom controls with WSPBuilder

Well we all know it is really easy to deploy web parts and other features with WSPBuilder.

When it comes to deploying custom controls, it  needs only the DLL to be deployed (and other additional artifacts that you may have with the control).

To deploy the dlls and create SafeControl entry with WSPBuilder:
create the Setup.exe.Config file and add the following two lines:

<add key="IncludeAssemblies" value="true" />

<add key="BuildSafeControls" value="true" />
That's it build the WSP again and deploy your custom control.
-- Mohan

Saturday, May 29, 2010

Linking ASP.Net Calendar to SharePoint Calendar - Day Click

Recently I came across a requirement where Calendar control was shown in a Page Layout and on day click of this calendar control, the user should be redirected to the SharePoint out of the box calendar showing that day.

ScreenShot: ASP.Net calendar control.

The calendar provides a OnSelectionChanged event. Create a new class that inherits from the calendar class and override OnSelectionChanged.  Find the date selected (clicked) on the calendar
and redirect to the Calendar day.

The good thing about the out of the box SharePoint Calendar is that it provides a simple mechanism to display a month or day view by passing parameters thru URL i.e.
CalendarDate  and CalendarPeriod

  1. CalendarPeriod can be month or day. If this is month - month view is shown and if this is day - that specific day is shown on the SharePoint Calendar page
  2. CalendarDate is date in the format mm/dd/yyyy

Here is the complete function for reference:

/// <summary>

/// Captures the Date click event and redirects to Calendar Day page

/// </summary>

protected override void OnSelectionChanged()


string url = string.Empty;

if (SPContext.Current != null)

/* Find the current site URL and prefix so that this works in all environment i.e. Dev, QA, Staging, Prod */
url = SPUrlUtility.CombineUrl(SPContext.Current.Site.Url, "Lists/My Calendar Name Here/calendar.aspx?CalendarDate={0}&CalendarPeriod={1}");

/* Since date is mm/dd/yyyy format , encode the date so that front slash is encoded. Also replace the value of  {0} i.e. First  and {1} i.e. Second parameter defined in the url string above. */
url = string.Format(url, SPHttpUtility.UrlKeyValueEncode(this.SelectedDate.ToShortDateString()), "day");

// Redirect the page to the Calendar day view


I will post a sequel to this i.e. how to link the title of the ASP.Net Calendar to SharePoint Calendar. Coming soon...

Please post your comments if you are reading this...

-- Mohan

Thursday, April 29, 2010

Automatic Redirection to the Data Form Web Part page on Close / Save / Cancel

In SharePoint - We know that if Source parameter is used in the QueryString in browser, the page is redirected back to the URL specified in Source querystring parameter.

While creating Data Form Web Part we need this functionality.

a) A link to create a new item in a list is specified in DFWP. When the user saves or cancels on the new page, it should be redirected back to the original page where this new link was specified
b) Links to a list item display page. After visiting the page, when user clicks Close on the page, again it should be redirected to the page from where the link was clicked on.

Since the DFWP can be on any page we want it to be generic so that on whichever page DFWP is placed i.e. say page X , after the destination page is visited and "close / cancel / ok" is clicked it should come back to page X.

Here is how to do it:
First create two parameters in DFWP as shown in the images below. These pick up values from Server Variables of IIS Server.

Now in DFWP where you specified a URL append this:

Source=<xsl:value-of select="$MyURL"></xsl:value-of>?<xsl:value-of select="$QS"></xsl:value-of>

(You also need to encode the strings)

and now when users click from the link specified in the URL and they hit close / cancel / save they
are redirected back to the page in Source querystring parameter.

This is what I have used in the past and now.

Have you used any other method for this? If yes - am interested to know.

-- Mohan

Tuesday, April 27, 2010

Display Today and Tomorrow events from a Calendar - using CAML

Here is the CAML


<FieldRef Name="EventDate" />

<Value Type="DateTime">

<Today />




<FieldRef Name="EventDate" />

<Value Type="DateTime">

<Today OffsetDays="1" />




The important part of this CAML is the OffsetDays keyword that allows to get future or past dates relative to Today. For example: Data for past 2 days would be OffSetDays="-2"

Well this one is a very well known formula, however I want to write this in my blog for quick syntax reference.

SharePoint Designer 2007: Page Processing error

On browsing the page layout from IE:

An error occurred during the processing of /_catalogs/masterpage/.aspx. Only Content controls are allowed directly in a content page that contains Content controls.

This means the Page Layout has possible tags above the Page tag.

Remove those tags (example: HTML, Head etc including the closing tags) and the error is gone....

Saturday, April 17, 2010

New properties in Web Part configuration

Well as you can see from the above screenshot there are 2 new sections  i.e. AJAX options and Miscellaneous. AJAX options are obvious. You could configure AJAX Load / Update / Refresh manually and refresh data automatically after predetermined # of seconds. If you want to display your own format for the List data - use XSLT in the XSL link from miscellaneous section.

Wednesday, March 31, 2010

Track time spent for your custom code

SharePoint 2010 has built in monitoring for tracking time taken for code operations.
We can use that in our custom code also: SPMonitoredScope
Since this uses IDisposable interface we will put in a using clause:

using (SPMonitoredScope monitorScope = new SPMonitoredScope("My Query Time Test"))
void myFunction()
// Function logic here


How to use the above:
Once we have the code compiled and deployed - and the developer dashboard is enabled (please see another post in this blog on how to enable developer dashboard) this will show us the length of time spent on executing myFunction. Neat ... Is'nt it?

Monday, March 29, 2010

SharePoint Designer 2007 giving issues - clear the cache..

Close SPD --> execute batch file --> Open SPD and check...

Put this in a batch file:
cd "%APPDATA%\Microsoft\Web Server Extensions\Cache"

del *.web /S /Q "%APPDATA%\Microsoft\Web Server Extensions\Cache"

cd "%USERPROFILE%\AppData\Local\Microsoft\WebsiteCache\"

rmdir /S /Q "%USERPROFILE%\AppData\Local\Microsoft\WebsiteCache\."

mkdir "%USERPROFILE%\AppData\Local\Microsoft\WebsiteCache"

dir "%APPDATA%\Microsoft\Web Server Extensions\Cache"

dir "%USERPROFILE%\AppData\Local\Microsoft\WebsiteCache"

Thanks to my friend Scott for creating a batch file for this.
I had done this manually in the past...

Friday, March 26, 2010

Failed to start the database service MSSQL$OfficeServers. Repair this product by selecting it from the Add/Remove Programs menu.

I had uninstalled this officeserver and installed SQL 2008 express for a demo server.
While there are some other solution available on this error: I fixed it by changing a different registry
Here it is:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\EvaluatorProvisioning\DatabaseEngine]


Changed the ServiceName value to the new SQL Express instance and Config Wizard started to work again...

Sunday, March 21, 2010

Using Locked Pages for SQL Server 2008

Select * from sys.dm_os_process_memory

gives us Information on locked pages.
How does that help? Locked pages can improve SQL Performance to an extent and afterall SQL is backend for SharePoint.

Here is very good article on AWE/PAE and other switches
Here is an excerpt from the above blog:
Now then, so why considering x64 Architecture if we have AWE?
The use of SQL Server (32-bit) with AWE has several important limitations. The additional memory addressability is available only to the relational database engine’s management of database page buffers. It is not available to other memory consuming database operations such as caching query plans, sorting, indexing, joins, or for storing user connection information. It is also not available on other engines such as Analysis Services.
For more detailed information, refer to:
Advantages of a 64-bit Environment

SQL 2005:
DBCC Memorystatus

Thursday, February 25, 2010

Error in the Site Data Web Service. (Exception of type 'System.OutOfMemoryException' was thrown.)

There were two things I changed after which the issue disappeared.

a) Found that an app pool was shared by two web app. Created a new App pool and assigned individual app pool to both web apps. Although one of the web app was not being used.
b) Changed the diagnostic logging for "All" events to Error only to remove excessive log writing.
After above 2 changes the following happened:

a) Error from indexing on Large list (50,000) items disappeared. Were getting same error earlier i.e. Error in data web service...

b) The crawl time reduced from 18 hours to 2 hours.

Long term solution: Migrate to 64 bit environment.

Find the # of items in SharePoint lists

SELECT TOP (10) tp_DirName, COUNT(tp_DirName) AS FolderItemsCount FROM AllUserData
GROUP BY tp_DirName
ORDER BY FolderItemsCount DESC

Friday, February 19, 2010

Get Id from Service Application thru PowerShell

From PowerShell prompt:

Get-SPServiceApplication | select id, name

Pipe i.e. "|" symbol is the same as earlier i.e. send the output of a command as input for one after |

Thursday, February 18, 2010

Http Request Throttling in SharePoint 2010

HTTP Request throttling basically rejects low priority requests when the server is overloaded - i.e. CPU usage going say 100%. Hence at this time low priority tasks like Search Crawl would be not run.

Having this value off means all low priroty requests will also be processed.

Deverloper Dashboard in SharePoint 2010

Issue the following command:

STSADM –o setproperty –pn developer-dashboard –pv on

use -pv off
to set it off.

Saturday, February 13, 2010

Multilingual Server Pack for MOSS 2007 Link - for Windows 2008 R2 x64

For instructions - use this link:
Deploying Multilingual Interface SharePoint 2007

Here is the link for operating system language files:

Windows 2008 R2 OS Language Files (All languages - 2+ Gb download)
This is DVD image - hence either burn it on disc or use the any Virtual Image mount software.

If you do not want all the languages and want to download individual files for OS then use the following link,
(select the language from the drop down first..)
 Windows 2008 R2 OS language files - Individual Language download

Now go to the regional - language settings of the OS (from control panel) and select the option to install this language. It will look for the path of the file downloaded. Specifiy that where above files were downloaded.

Next comes MOSS 2007 Language packs:
1. WSS 3.0 Language Pack

2. WSS 3.0 Language Pack SP2

3. MOSS 2007 Language Pack

4. MOSS 2007 SP2 Language Pack

Yes that is correct - you need WSS language files also for MOSS 2007.
The above should be installed in the same order and after each of the 4 steps -  run the SharePoint configuration wizard. Do not disconnect from the farm if that options shows up.

I hope this becomes easier in future but for now this is what it is for MOSS 2007.

Friday, February 12, 2010

New Names in SharePoint 2010

SharePoint 2007              SharePoint 2010
  1. BDC                       BCS (allows editing of data now)
  2. SSP                        Service Applications. Example: Performance Point SA,Excel SA   
  3. SSO                        STS (Secured Token Service)
  4. WSS                       SPF (SharePoint Foundation Server)
  5. MOSS                    SPS (SharePoint Server)

Cancel or other links not working from IE in central admin

Go to server manager in Windows 2008 and disable the enhanced security for Administrator (assuming you are logged in as Administrator)
and try central again... it works...

Thursday, February 11, 2010

Cloning a VM - useful for installing SharePoint with VM for different roles...

Install all the latest service packs
Disconnect from AD if connected.

Use sysprep and shutdown. Sysprep.exe is available in Windows sub folder.

Now you can make copies... Just need the Activation key when you start up... easy...

MOSS 2007 on Windows 2008 R2 x64

Windows 2008 R2 X64 needs atleast MOSS 2007 with SP2 otherwise you will get "compatibility error" on running setup.exe.

If you have MOSS 2007 or MOSS 2007 SP1: extract the files if they are not already extracted in folder structures. say MOSS2007

Similary extract the MOSS 2007 SP2 in a different folder say MOSS2007SP2

Look for a subfolder Updates in MOSS 2007. Delete any existing files in update folder. Copy all the files from MOSS2007SP2 into the update folder.

Run setup.exe and it works....

SharePoint 2010 Event Reciever Debugging

Attach to the SP Timer V4 and not W3P.exe since now event recievers run under SharePoint Timer.