Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Webpart doesn't update when property changes are applied.

  Asked By: Tami    Date: Apr 21    Category: Sharepoint    Views: 3537

I have a custom webpart, with custom properties.
The behavior:
I edit the webpart, and make a change to a custom property and click
the apply button in the property pane. At this point the properties
in the property pane will show the new values, but the rendered
webpart does not. I click apply a second time, and then both the the
webpart and the property pane both so the change. Basically I have to
click the apply button twice to my the property changes take effect.

My webpart implements:
and a handful of properties
My EditorPart implements:
and a handfull of Controls

My understanding is that ApplyChanges is supposed write changes to
the webpart, SyncChanges is suppose to update the changes in the
propertyPane, and Render draws the propertyPane.

What appears to be happening is the webpart is being render before
the changes are applied. Hence the why the changes show on the 2nd
click of apply.

Am I missing a method somewhere? Or any thing else I should look at?



3 Answers Found

Answer #1    Answered By: Joshuah Huber     Answered On: Apr 21

Try hitting apply  once, checking in the page,
publishing, and refreshing.

Answer #2    Answered By: Ciara Collier     Answered On: Apr 21

You must wait until after viewstate has been saved for the response
before accessing the public properties  of your Web Part. That means that
in CreateChildControls you construct your interface but you must wait
until RenderContents to use the public properties set in the EditorPane
or within code.

Answer #3    Answered By: Keenan Whitehead     Answered On: Apr 21

it's working as expected now.
Moved my webpart  display code from CreateChildControls to
RenderContents, and changed the moved the editorPart Render to

Didn't find what you were looking for? Find more on Webpart doesn't update when property changes are applied. Or get search suggestion and latest updates.