I have broken up a humongous page into several "bite-size" chunks. I want to present them, one at a time, to the user. After one page, they click an HTML button ("Next") and the previous Web Part or Content Editor Web Part is replaced by the next one.
From this page, I came up with some pseudcode (I don't know if there really is a SPLimitedWebPartManager.RemoveWebPart() method that I can call, as pseudocoded below, or how to get a reference to the currently (about-to-be-replaced) [Content Editor] Web Part, but this is the basic idea:
using (SPSite site = new SPSite("http://~"))
{
SPWeb web = site.RootWeb;
SPFile page = web.GetFile("Pages/Web_Form_Post_Travel_Expense.aspx");
page.CheckOut();
using (SPLimitedWebPartManager wpmgr = page.GetLimitedWebPartManager(PersonalizationScope.Shared))
{
XmlElement d = new XmlDocument().CreateElement("div");
d.InnerText = get
ContentEditorWebPart cewp = new ContentEditorWebPart
{
Content = d
};
ContentEditorWebPart currentCEWP = ?;
wpmgr.RemoveWebPart(currentCEWP);
wpmgr.AddWebPart(cewp, "Header", 0);
}
page.CheckIn(String.Empty);
}
Does this make sense? It seems kludgy or even downright weird to me, to be checking out the page, changing it, and checking it back in.
The only other thing I can think of at the moment is to put the entire shebang into one Web Part, but keep sections 2-6 hidden at first, and then successively show one segment (after hiding the previous one). IOW, this type of procedure:
First Section shows
All others hidden
User selects "Next" button
First section is hidden
Second section shows, while all others remain hidden.
etc.
Actually, both ideas seem at least a little wonky to me. Is one approach preferable, or is there a third way I haven't thought of that would be better than both?