Monday, January 30, 2012

RadGrid - AutoFit columns in a grid

Call the following function on page load to force the RadGrid to auto size the columns:

function pageLoad() {
var grid = $find("RadGrid1");
var columns = grid.get_masterTableView().get_columns();
for (var i = 0; i < columns.length; i++) {

Friday, January 27, 2012

Thursday, January 19, 2012

Getting Session State in HttpHandlers (ASHX files)

A reminder to myself and others, when you want to get access to your Session State from an ASHX or HttpHandler, you need to implement IReadOnlySessionState:

<% @ webhandler language="C#" class="DownloadHandler" %>

using System;
using System.Web;
using System.Web.SessionState;

public class DownloadHandler : IHttpHandler, IReadOnlySessionState
public bool IsReusable { get { return true; } }

public void ProcessRequest(HttpContext ctx)


Moving SharePoint Content Database Files To New Location

Often you need to relocate your MOSS database files to a new partition, drive, or SAN, while leaving them attached to the same SQL Database Instance.

1. Prepare SQL Script

Alter the database file names using the scripts listed down below. Modify the scripts as appropriate for each database.

If the database has dashes in the name you have to put quotes around it.

2. Run the Script

Run the script in SQL Management Studio, or Management Studio Express. You should get a result indicating that the paths have been altered for the databases.

3. Stop SharePoint and SQL Server

Stop IIS, or the web applications your SharePoint site. Stop MSSQL Server through Management Studio or via the Windows Service.

4. Move the databases to the new location

Copy the mdf and log files to the new location (new drive, partition, etc).

Please copy and then delete, as opposed to trusting a cut+paste operation.

5. Start the SQL services

Start MSSQL either through Management Studio or via the Windows Service.

6. Verify access to each database

Verify the databases are working properly, you can just pull up the properties to the database in Management Studio.

7. Start SharePoint services

Start IIS, web apps, or whatever you disabled in step 3.

Go verify your SharePoint site is working.

8. You are Done.

Go get coffee, pat yourself on the back, etc.

The SQL Script:




ALTER DATABASE SharePoint_Configuration_DB

MODIFY FILE (NAME = SharePoint_Configuration_DB_log ,FILENAME = ‘D: \Data\SharePoint_Configuration_DB_log.LDF’)


ALTER DATABASE “SharePoint_AdminContent_ce805cd0-0b6d-4ea1-8eaa-469b1ea0296a”

MODIFY FILE (NAME = ‘SharePoint_AdminContent_ce805cd0-0b6d-4ea1-8eaa-469b1ea0296a_log’ ,FILENAME = ‘D: Data\SharePoint_AdminContent_ce805cd0-0b6d-4ea1-8eaa-469b1ea0296a_log.LDF’)


Keep in mind that moving the database may cause SharePoint to perform a full crawl in place of a regularly scheduled incremental crawl at the next crawl interval.

Go here to get more information from MSDN.