I have a web part exposed as a widget. It contains a few controls that need to be data bound. I only want to bind the data when not posting back. I therefore have the following code: public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}
public override void ReloadData()
{
base.ReloadData();
SetupControl();
}
protected void SetupControl()
{
if (StopProcessing)
{
// Do nothing
this.Visible = false;
}
else if (!RequestHelper.IsPostBack())
{
// Bind my controls
}
}
This works find on the live site. However, in Page tab I'm finding that when an editor edits the widget's configuration, then saves and closes the widget dialogue, the page reloads and my data bound controls are now empty.When debugging I can see that this re-load is a postback, but somehow my controls have lost their bindings. Has anyone experienced similar?I've tried changing my SetupControl method to the following:protected void SetupControl()
{
if (StopProcessing)
{
// Do nothing
this.Visible = false;
}
else if (!RequestHelper.IsPostBack() || !this.IsLiveSite)
{
// Bind my controls
}
}
But for some reason the IsLiveSite property is true (and CMS.PortalEngine.PortalContext.IsDesignMode(this.PagePlaceholder.ViewMode) is false). So how can I ensure that my control is only bound on initial page load, but changed to widget configuration also cause a re-binding?
↧