We are creating content databases, site collections and libraries programmatically. Then we are uploading documents in document library. We want to create event receivers programmatically in C# (without using Visual Studio) as soon as list is created programmatically? Also want to activate them programmatically. Is there any way to do this? Can you please provide me any code through which I will get step by step guide?
Asked
Active
Viewed 1,607 times
1 Answers
0
If you can use the event receiver template in visual studio and than define a C# code for the required event might solve your purpose. Like for ItemAdded event receiver I did something as simple as this:
public override void ItemAdded(SPItemEventProperties properties)
{
if (properties.ListTitle.Equals("cl2"))
{
using (SPSite site = properties.OpenSite())
{
using (SPWeb web = site.RootWeb)
{
string sytr = web.Url.ToString();
string s = web.PortalUrl.ToString();
string sq = web.ServerRelativeUrl.ToString();
string str = site.Url.ToString();
SPListItem _currentItem = properties.ListItem;
cItem["Title"] = "Test";
cItem.Update();
base.ItemAdded(properties);
}
}
}
}

Amit
- 194
- 4
- 20