I have a custom web part that has the default toolpart and one additional custom property. I have a use case that requires me to be able to access the value of Title within the web part (this.Title) so that I can change its value immediately after a user changes it. However, any place I call this.Title from within my code after Apply Changes is clicked will show the previous value of the title. How can I access the just-entered Title?


Title value is "My Title".

User clicks edit web part.

User changes the title to "Different Title".

User clicks "ok" or "apply changes".

My code grabs "My Title" instead of "Different Title", although the next time the page loads, it will grab "Different Title". :(

I've tried overriding various methods like OnInit, OnPreRender, OnLoad, and CreateChildControls, but it doesn't seem like I can access the just-updated property in the page lifecycle.

Is there a simple way I can access this property in my code? Thanks.

  • Matt, Did you solve the issue? If one of the answers helped you out please mark as answered. Jun 13, 2011 at 11:03
  • Yes, I'll add my own answer that specifically addresses the problem within the next day or so (as I'm busy at the moment). Jun 13, 2011 at 15:30

5 Answers 5


One solution is to set up the values for your web part in the OnPreRender event -- I've done so in an example of "Web Designer Friendly Web Parts" on SharePoint 2007. Since we didn't have a custom EditorPart, SyncChanges and whatnot wouldn't have worked anyway.


I've had this problem a lot with web parts I developed with jQuery code. The only way I got it to show after hitting the apply was to use the Render Event to display the web part. It's been a little bit of a hassle building the code here--but for my projects it's worked.


In the EditorPart the methods ApplyChanges and SyncChanges can be used to set your own title at all times:

YourWebpart wp = (YourWebpart)this.WebPartToEdit;
wp.Title = "Title from code";

That is because of the way SharePoint (or better, the ASP.NET framework) works. The events are fired in a certain order, the ApplyChanges is fired to late in the event sequence, so any update will only be shown after you refresh the page. Clicking Apply first and then OK would show the correct title though (apply sets the change, Ok just does it again but since it is already set it will show when you are the ok click redirects you back out of the edit screen.


You may also try overriding the OnEditModeChanged event of the base webpart class and set your propeties in that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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