In Sharepoint, SP.UI script namespace provides required methods and classes for showing different types of dialogs.

The following are the list of various dialog methods available under class ModalDialog

1) showModalDialog: To show a modal dialog with some options.


2) ShowPopupDialog :

To show a modal dialog with an url and without any options.

3) showWaitScreenSize : this one is used to show a wait screen dialog with a close button


for more information on options visit

4) showWaitScreenWithNoClose:

To show a wait screen without any cancel button.


5) commonModalDialogOpen(url,options,callback,args)

To show a modal dialog with url, options, callback, parameters.

SP.UI.ModalDialog.commonModalDialogOpen(url, options, callback, parameters);

ModalDialog class provides other non dialog methods

1) RefreshPage:


2) close:
To close a dialog.

for showModalDialog and commonModalDialog, there are two ways to pass the options

//generic way

var options = { title: ‘Dialog1’ .height: 300 ,width:300
,url : ‘’

//with DialogOptions class

var options = SP.UI.$create_DialogOptions();
options.title = ‘Dialog1’;
options.height = 300;
options.url = ‘’;

You can also display html string instead of url but have to do in indirect way. Options html property takes a DOM element as an input. When html and url properties are provided, url takes precedence.

var div = document.createElement('div');
div.innerHTML = 'Dialog html demo Dialog html takes an DOM object but not an html string';
var options = {    title: 'Dialog1',
width : 300
,html = div

To refresh a page after dialog ok clicked.

Sharepoint 2010 provides a custom tag ScriptLink to register script files in a webpart. This can also be done using simple html script tag but using ScriptLink ensures all the sharepoint script namespaces are available for your custom script.

All the scripts that are to be registered should be placed in Layouts/ProjectName folder of your project. By default, when you create a project Layouts folder will not be added.

To add it, right click on your project –> add –> SharePoint “Layouts” Mapped Folder

A default folder with project name will be automatically created under Layouts folder.

Add your custom script files in Layouts/ProjectName/Scripts folder (create Scripts folder if not exist, it can be any name like JS etc.).

Add your code in the script file, here in this example I have added some alert code which is opened by clicking on web part button ‘click here’

Now add ScriptLink tag in your visual web part (i,e. .ascx control)
If you want to do the same in a standard web part, add the below code in OnPreRender method

ScriptLink.register(page,”RajWebPartsDemo/Scripts/RajDemoScript.js”, false);

Deploy your solution and add a your webpart in a page (say home page).

On clicking button ‘Click Here’ an alert is displayed.

Site Definition and Web Template are used for building a SharePoint site. If you are new to SharePoint, you may wonder which one to use?. Well, it depends on your site requirements and extensibility. Both are used to build a site UI interface to the end user.  The major difference is a Web template is always based on a existing Site Definition either directly or indirectly. I have outlined some comparisons in the below table


Site Definition

Web Template

core definition in SharePoint Based on existing Site Definition either directly or indirectly
Stored on a Front-end Web Server in folder

%ProgramFiles%Common FilesMicrosoft Sharedweb server extensions14TEMPLATESiteTemplates

Stored as a .wsp file in SharePoint Database.
Complex to create Easier to create
Deployed as Farm solutions with Admin rights Deployed in Solution Gallery(Sandbox)
Once def, cannot be modified can be modified without affecting existing sites
Configurations are defined in WebTemp*.xml and ONET.xml
WebTemp*.xml file contains one or more Template elements which represents a Site Definition
Details of each Template element in WebTemp*.xml are stored in a corresponding Configuration element in the ONET.xml file.
Configurations are defined in a xml and ONET.xml(part of .wsp file).

In the XML, The only difference is WebTemplate element instead of Template as defined in WebTemp*.xml.

The ONET.xml is simpler than that of Site Definition ONET.xml.



1) Sites created from a Site Definition or Sites created from a Web Template (that is based on the Site Definition) may not work properly if modified or removed. New sites based on Site Definition cannot be created. 

2) Out of Site Definition and Web Template, Web Template is easier to create ,maintain, modify and deploy. A Site definition is preferred, when you need custom components(defined in ONET.xml) and email footers,.

3) If you go for a Site Definition, the best practice is to have a minimal Site Definition to be acted as model and extend it with using Site Features whenever required.

A SharePoint site definition is the core definition of what a site in SharePoint. A site definition can include more than one site definition configurations i.e. family of configurations.  A configuration specifies the sets of lists, Features, Modules etc. that are included when a new site is created.

Each site definition is a combination of .aspx , .ascx, .master along with .xml file in Collaborative Application Markup Language(CAML) that are placed in %Program Files%Common FilesMicrosoft Sharedweb server extensions14TEMPLATESite Templates.

Every site definition structure and content is governed by a set of XML files in CAML format. Prominent among them are

WebTemp*.xml : Provide information about how they appear in the UI.

When SharePoint installed, a global WebTemp*.xml is installed in %Program Files%Common FilesMicrosoft Sharedweb server extensions14TEMPLATELCIDXML

where LCID is the numeric ID of language/culture. ex: 1033 for English.

For each site definition, there will be one WebTemp*.xml.

General format of WebTemp*.xml is as shown below

      <Template Name=”<name>” ID=”ID1”>

        <Configuration ID=”<someid>” Title=”title">


         <Configuration ID=”<someid>” Title=”title">



      <Template Name=”<name>” ID=”ID1”>



    … …


Each <Template> element represents a site definition. Every Site Definition is provided with one or more <Configuration> elements. If you want to know more about <Configuration> element, follow this link

Onet.xml : All about Navigation areas, List Definitions, Modules, Document Templates, List Templates, Configurations, BaseTypes, Components.

When SharePoint installed, a global Onet.xml is installed in %Program Files%Common FilesMicrosoft Sharedweb server extensions14TEMPLATEGLOBALXML.

For each site definition, there is a corresponding Onet.xml installed in subdirectory(template name) at  %Program Files%Common FilesMicrosoft Sharedweb server extensions14TEMPLATESiteTemplates

Click on this link to know more about format of Onet.xml file.

A Site definition deployed once cannot be modified. The best way is to create a new kind of site. This can be done by creating a new WebTemp*.xml and Onet.xml. 

Few points to remember

  • SharePoint 2010 must be installed on the dev machine. No longer Visual Studio 2010 supports remote debugging for SharePoint.
  • Instance of Visual Studio 2010 must run with elevated permissions i.e. Run as Administrator.


  • Solution must be deployed as  Farm solutions rather than as Sandbox solutions.

Please follow this link if you want to what is a Sandbox solution in SharePoint 2010.

Follow this link to know differences between Farm solutions and Sandbox solutions.

Creating a Site Template

To create a site template follow these steps

1) Open Visual Studio 2010 (as administrator), Click on File->New->Project. Select the Site Definition project template under SharePoint 2010 templates folder. Provide solution name and location, Click Ok button.


2) Next you’ll see a SharePoint Customization Wizard asking for local site for debugging and deployment. Provide your SharePoint Url and select Deploy as a Farm Solution radio option and then Click Finish.


3) A new solution will be created as shown in the below image. Note that two xml(WebTemp*.xml, ONet.xml) files are created. And also Features and Modules


4) Click Build->Deploy, solution will be deployed on the SharePoint. All Done.

5) Open SharePoint Central Administration Web page, create a new site from your custom site definition.


6) Open newly created site, you’ll see a custom site web page derived from your site definition.


SharePoint 2010 is currently available in 3 editions

  • SharePoint Foundation 2010
  • SharePoint Server 2010 Standard
  • SharePoint Server 2010 Enterprise

SharePoint Foundation 2010 is the newest version of Microsoft Windows SharePoint Services(WSS). It has minimal features when compared to the other editions.

Click on the below link to know the features in all the editions

All the editions of SharePoint 2010 will run on 64bit OS only. For more information on requirements and configuration, see

SharePoint Foundation 2010 requires a minimum of 4GB Ram for evaluation purposes and 8GB Ram for production use.

For evaluation purposes, Installing SharePoint Foundation 2010 on a developer machine can be a bit messy as it requires lot of resources and configurations. Most of the developers prefer a virtual machine(VM) to isolate SharePoint which will not hinder any normal machine configuration and resources.

There are lot of virtualization software’s out there in the market say Microsoft Virtual PC, Virtual Box, VMWare etc.

Microsoft Virtual PC is a free software but doesn’t support a 64 bit Guest OS. VMWare is a good software but its commercial. I preferred VirtualBox because it can support all types of Guest OS and is a free software. You can download it from

My system configuration is as below

Host OS : Windows 7 64 bit

Guest OS : Windows 7 64 bit


Installing Guest OS Windows 7 in VirtualBox

1) Download and Install VirtualBox software from .

2) Create a new Virtual Machine by clicking on New to start a New Virtual Machine Wizard and click Next.


3) Type Name of the OS and choose OS Type, Version and Click Next.


4) Choose the amount of RAM required for the guest OS. It should be usually 30% of available RAM


5) Create a new virtual hard disk. Ensure Boot Hard Disk is checked.


6) A new Virtual Hard Disk will pop up. Choose Dynamically expanding storage and click Next.


7) Choose the location of virtual disk file and the size. Its best to allocate between 40GB-60GB space. Click Next and Finish.


8) The guest OS will show as Powered Off, so click on it and choose Start.


9) Once you click start, A first time run wizard will popup asking for location of Windows7 iso image file. If you have a installation cd or dvd, just point out to iso file otherwise you will receive an error no bootable medium found

If you receive this error, power off virtual machine, click on File->Virtual Media Manager from virtualbox main window



10) A new window box will popup with media manager settings. Click on CD/DVD Images. Click on Add, a file browser window will popup Online Pokies, locate installation iso file and click ok.


11) Select virtual machine and click on settings. Check for boot order, ensure CD/DVD ROM checked(prior to Hard Disk) and click Ok.


12) Now select virtual machine, click on Start. virtual machine starts windows 7 installation.

Installing SharePoint Foundation 2010 on Guest OS Windows 7

SharePoint Foundation 2010 on guest OS windows 7 requires OS to have certain prerequisites installed before installation begins.

The following prerequisites must be installed on guest OS Windows 7

SharePoint includes a PrerequisiteInstalle.exe tool that installs all of these prerequisites for you but it will run only on Windows Server 2008. In a one go, you can install Visual Studio 2010 to have all of these prerequisites except Windows Identity Foundation otherwise download and install them manually. 

Before installation begins, the following required windows features have to be enabled otherwise installation fails.



If you want a share a folder from Host OS to Guest OS, install VirtualBox guest addons from virtual machine main menu->Devices->Install Guest Additions. After install, add shared folders through Virtual machine main menu->Devices->Shared Folders

Here is an excellent article explaining how to add shared folders

Installation Steps

1) Download SharePointFoundation.exe from Microsoft website.

2) By default, the downloaded file cannot be installed on Windows 7 as it requires Windows Server 2008 and it gives following error


  In order to install on windows 7, a config file has to be modified to allow installation.

      a) Copy the SharePointFoundation.exe (or setup.exe) installation file to a folder

      b) Extract the installation files by opening a Command Prompt window and then typing the following command at  

          the directory location of the folder

            c:SharePointFilesSharePoint /extract

      c) open the installation configuration file, config.xml, located in the following path: filesSetupconfig.xml

      d) Add this line inside the <configuration> tag:

          <Setting id=”AllowWindowsClientInstall” Value=”True” />

  3) Open Setup.exe from the installation directory, A setup windows will popup.

  4) Accept Microsoft Software License Terms.

  5) Choose Standalone installation on Choose the installation you want page.


  That’s it SharePoint 2010 will be installed successfully, if you followed above steps as it is.

Running Configuration Wizard

After you install SharePoint 2010, a Configuration wizard has to be run in order to setup SharePoint configuration and settings. The setup wizard shows an checkbox option to configuration wizard in the final step otherwise you can run it from Programs –> Microsoft SharePoint 2010 products-> Configuration Wizard.

After the configuration wizard is complete, you see the new SharePoint site.