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
27 May 2009
13 May 2009
Registing Event Handler on a list/library
for Registering the Event Handler following are the steps to be followed:
<--CODE-->
static void Main(string[] args)
{
try
{
string AssembleInfo="EventHandlerRegister, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d53fad3f8a2d2037" ;
String ClassName="Akshaya.EventHandlerRegister";
RegisterEvent(http://registerSite/Sites/site, "MYCustomListName", AssembleInfo, ClassName);
Console.WriteLine("Event Registered Successfully......");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
Function for registering this Handler
<--CODE-->
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);
MyWeb.Close();
}
}
now check the list event firing and incorportating those changes.
Thanks: Akshaya
- Add a Console application project in the Event Handler applcation.
- Add the DLL of Event Handler in the GAC.
- Now include the following code the console application.
<--CODE-->
static void Main(string[] args)
{
try
{
string AssembleInfo="EventHandlerRegister, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d53fad3f8a2d2037" ;
String ClassName="Akshaya.EventHandlerRegister";
RegisterEvent(http://registerSite/Sites/site, "MYCustomListName", AssembleInfo, ClassName);
Console.WriteLine("Event Registered Successfully......");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
Function for registering this Handler
<--CODE-->
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);
MyWeb.Close();
}
}
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.
<--Code-->
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);
//}
}
}
All that needs to be carried is create a event handler with overriding methods ItemAdded or Itemupdated.
<--Code-->
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);
//}
}
}
11 May 2009
Cascading Parent Child inter-relation in sharepoint
this is really a wonderful article added by Mayuresh for providing relation between 2 webparts.
http://mayureshsharepoint.blogspot.com/2009/05/cascading-with-parent-child-relation.html
Special Thanks to Mayuresh Telvekar.
Subscribe to:
Posts (Atom)