I need to change the displayname of a list using "ItemUpdating". The source of the new name is the "Title"-field of the item which fires the event. Is this possible? I tried it with:
if ((properties.ListTitle == "Fahrzeuge") || (properties.ListTitle == "Räume"))
{
base.ItemUpdating(properties);
try
{
base.DisableEventFiring();
string origCalTitle = properties.ListItem["Title"].ToString();
string newCalTitle = properties.AfterProperties["Title"].ToString();
if (origCalTitle != newCalTitle)
{
using (SPWeb web = properties.OpenWeb())
{
CultureInfo origCulture = Thread.CurrentThread.CurrentUICulture;
web.AllowUnsafeUpdates = true;
SPList changeList = web.Lists[origCalTitle];
Thread.CurrentThread.CurrentUICulture = new CultureInfo((int)web.Language);
changeList.Title = newCalTitle;
changeList.Update();
web.AllowUnsafeUpdates = false;
}
}
}
finally
{
base.EnableEventFiring();
}
}
I also tried it on some other way, like ItemUpdating and Afterproperties but nothing happens. Unfortunately I am not a pro in programming Event Receiver und also Google doesn´t help me out, so I need help.
Thanks for all effort!