Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a webpart with several properties that are part of a custom ToolPart. When i set the properties i would like the webpart to reflect the property changes while still editing after having clicked Apply/Ok but the page is still in Edit mode (i'm guessing in the ApplyChanges of my custom tool part). Any ideas?

TIA

share|improve this question
    
After you make the changes , click on OK instead of Apply and close the edit mode page. Now save the page and browse back again and let me know the changes are getting reflected or not. –  Arko D May 31 '12 at 17:25
1  
That works....i was wondering, however, if there was a way to re-render the webpart with the changed properties while still in edit mode after hitting Apply. I was thinking that there might be a way in the ApplyChanges method –  MikeC May 31 '12 at 17:35
add comment

1 Answer

up vote 2 down vote accepted

This purely depends on where in the life cycle of the Web Part you use the properties.

If you use the values early before the "ToolPane" gets the clicked event for Apply/OK which causes your ToolParts ApplyChanges to fire and change the properties, well then the changes wont show up until next pageload.

If you use the values late (after the clicked event) then the change will show up "immedately".

In my advanced web part below changes to TestCCC will not show until next pageload because I call EnsureChildControls in PageLoad which the adds the LiteralControl before the clicked event. Changes to TestRC which is will show immediately because it's rendered out late.

public class TestEditWP : WebPart
{
    [Personalizable(PersonalizationScope.Shared)]
    [WebBrowsable(true)]
    public string TestCCC { get; set; }

    [Personalizable(PersonalizationScope.Shared)]
    [WebBrowsable(true)]
    public string TestRC { get; set; }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        EnsureChildControls();
    }
    protected override void CreateChildControls()
    {
        Controls.Add(new LiteralControl(TestCCC));
    }

    protected override void RenderContents(HtmlTextWriter writer)
    {
        base.RenderContents(writer);
        writer.Write("{0}", TestRC);
    }
}
share|improve this answer
add comment

Your Answer

 
discard

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.