Custom widget/webpart won't display until page is saved - I'm missing something obvious

Neil Fennessey asked on October 16, 2018 21:00

I've done this before but cannot find the code I used before.

I created a custom webpart that has a simple drop down list (that's an example, the actual web part is far more complicated). I turned it into a widget and I'm dropping this in on the page tab in a editor webzone. The widget won't appear until after I've saved the page. It should show as soon as I drop the widget in there.

I know I fixed this before but can't recall the exact code. The fix is in the code behind and relates to page load I think. This is going to be obvious. Anyone have a quick second to answer?

Thanks

Correct Answer

Brenden Kehren answered on October 16, 2018 21:17

Where are you loading your controls in your webpart code? Page_Load is too late in most cases for using portal engine development. This typically needs to happen on every page load in the event below:

public override void OnContentLoaded()
{
    base.OnContentLoaded();
    // do your work here
}
0 votesVote for this answer Unmark Correct answer

Recent Answers


Neil Fennessey answered on October 16, 2018 21:28

That's it - and I was just about to try this as it looked familiar. Thanks.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.