27 May 2009

Interview Preparation

For the Sharepoint resources looking for a change get an outline here,which is well categorised. hope this blog helps you.
Click here

Special thanks : yagyashree

13 May 2009

Registing Event Handler on a list/library

for Registering the Event Handler following are the steps to be followed:

  1. Add a Console application project in the Event Handler applcation.

  2. Add the DLL of Event Handler in the GAC.

  3. Now include the following code the console application.

static void Main(string[] args)

string AssembleInfo="EventHandlerRegister, Version=, Culture=neutral, PublicKeyToken=d53fad3f8a2d2037" ;
String ClassName="Akshaya.EventHandlerRegister";
http://registerSite/Sites/site, "MYCustomListName", AssembleInfo, ClassName);
Console.WriteLine("Event Registered Successfully......");
catch (Exception ex)

Function for registering this Handler
private static void RegisterEvent(string SiteUrl, string ListName, string AssemblyInfo, string ClassName)
using (SPSite mySite = new SPSite(SiteUrl.Trim()))
SPWeb MyWeb = mySite.OpenWeb();
SPList MyList = MyWeb.Lists[ListName];
//include the event handler you have overrided in your handler.ex her is Itemadded
MyList.EventReceivers.Add(SPEventReceiverType.ItemAdded, AssemblyInfo, ClassName);


now check the list event firing and incorportating those changes.
Thanks: Akshaya

12 May 2009

Creating Sub-Site on List item added using event Handler

Creating a Sub site when a new item is added in the list.
All that needs to be carried is create a event handler with overriding methods ItemAdded or Itemupdated.

string Url = "http://Site_URL/sites/demo";
using (SPSite oSite = new SPSite(Url))
using (SPWeb oWeb = oSite.OpenWeb())
SPList projectList = oWeb.Lists["MYCustomList"];
//foreach(SPListItem listItem in projectList)

string projectName =properties.ListItem["Title"].ToString();
SPWebCollection collWebsites = oWeb.Webs;
oWeb.AllowUnsafeUpdates = true;
oWeb.Navigation.TopNavigationBar.Parent.IsVisible = true;
string strWebUrl = projectName;
string siteTitle = projectName;
string siteDescription = "Sub site created by code.";
collWebsites.Add(strWebUrl, siteTitle, siteDescription, 1033, "MyTeamSitetemplate.stp", true, false);


Rate Now: