first create one event receiver, sample code (not tested, just to give some basic idea)
public class YourClass: SPItemEventReceiver
{
public override void ItemAdded(SPItemEventProperties properties)
{
SPListItem item=properties.ListItem;
item["YourFieldNameInWhichYouWantToPlaceCustomText"]="Custom Text";
//any other logic
item.Update(); //must!!! or you can use item.SystemUpdate() also based on your requirement
}
}
then create another feature receiver
public class MyFeatureReceiver: SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb web = properties.Feature.Parent as SPWeb;
if (web != null && web.Lists["YouList"] != null)
{
web.Lists["YourList"].EventReceivers.Add(SPEventReceiverType.ItemAdded,
"Featurename, Version=1.0.0.0, Culture=neutral, PublicKeyToken=token",
"EventReceiverClass");
}
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPWeb web = properties.Feature.Parent as SPWeb;
if (web != null && web.Lists["YourList"] != null)
{
SPEventReceiverDefinitionCollection Recievers = site.Lists["YourList"].EventReceivers;
//delete event receiver or perform some other activity
}
}
}
that's all in a nutshell, if you dont have explicit reason, i would suggest go with ItemAdded rather than ItemAdding, ItemAdding shoudl be used only when synchronous activity is required, if you still face problem kindly post your code here