I have a custom webpart, i am trying to get to do a one-click transition from WebPartManager.BrowseDisplayMode
to SPControlMode.Edit
. Unfortunately, there is no direct means of transitioning between these two very different modes. But i have built, maybe a successful process but need some help, as the behavior is kind of silly.
So i have a Link Button, with the text "Edit", in the event that the Properties are not set. This situation would be the case where someone comes in and drops the controls on a page and then later on fills in the properties for execution.
Link Button Click event:
void lbtnViewEdit_Click ( object sender , EventArgs e ) {
if ( WebPartManager.DisplayMode == WebPartManager.BrowseDisplayMode) {
WebPartManager.DisplayMode = WebPartManager.DesignDisplayMode;
//SPContext.Current.FormContext.SetFormMode( SPControlMode.Edit , false );
}
}
And then i started playing with the FormContext DisplayMode settings. Currently it is in the CreateChildControls()
event, as i was playing with the event models.
protected override void CreateChildControls () {
if ( WebPartManager.DisplayMode == WebPartManager.DesignDisplayMode ) {
SPContext.Current.FormContext.SetFormMode( SPControlMode.Edit , false );
}
base.CreateChildControls();
}
The behavior i am currently experiencing, maybe a postback behavior, but i am unsure.
From the BrowseDisplayMode
(Published Page), i see the Edit LinkButton. But when i click the Edit button, i have to click it twice to get to the SPControlMode.Edit
Mode. The second click of the LinkButton gets me to the display i want to be in, but i would like for it to be a single click transition from a Published Page view to a Edit display, similar to clicking the Edit
from the Ribbon.
Any help on which process i should use, would be greatly appreciated.