SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a meetings list, when a new event is created a subsite is created with an specific format. The list allows to change the date of the events, but when this happens the name of the subsite and its url are not changed.

I need to be able to do this by code, so I am coding an ItemUpdated event. However the Url Property is readonly. How can I change this by code? I did using the interface and its possible.

 public override void ItemUpdated(SPItemEventProperties properties)
            Logger.LogDebug("MeetingCalendarEvents", "ItemUpdated(SPItemEventProperties properties)", "BEGIN");
                base.EventFiringEnabled = false;
                SPSite site = properties.Web.Site;                
                SPWeb web = site.AllWebs[properties.BeforeProperties["Title"].ToString()];

                web.AllowUnsafeUpdates = true;
                web.Title = properties.AfterProperties["Title"].ToString();
                web.url = properties.AfterProperties["Title"].ToString(); //wont compile

                web.AllowUnsafeUpdates = false;

            catch (Exception ex)
                Logger.LogError("MeetingCalendarEvents", "ItemUpdated(SPItemEventProperties properties)", ex);
                properties.ErrorMessage = ex.Message;
                properties.Cancel = true;
                base.EventFiringEnabled = true;
            Logger.LogDebug("MeetingCalendarEvents", "ItemUpdated(SPItemEventProperties properties)", "END");
share|improve this question
Repost of… – RJ Cuthbertson Aug 2 '12 at 15:07
up vote 1 down vote accepted

Try SPWeb.ServerRelativeUrl for re-parenting webs.

share|improve this answer

I think you can set the SPWeb.Name property instead of SPWeb.Url. SPWeb.Name is an empty string if it is the root web.

share|improve this answer
so if I change the name the url will change? – Esteban V Aug 2 '12 at 12:40
Yes, that should do the trick. – marco Aug 2 '12 at 12:41
This is the same solution presented in… I'm surprised by this. I can see this working on new site creation, but I'm curious about whether or not this alters existing sites. I'd like to know what you find. – RJ Cuthbertson Aug 2 '12 at 15:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.