In the current project it's a requirement to create PublishingPages on a code-behind of an application page and redirect to that Page afterwards.
There're two little stumbling blocks you have to watch out. The first is, that you have to check out the newly created PublishingPage before redirecting, otherwise you'll get a nice error-message of type "You have not checked out this page. Click 'Edit Page' to edit the page.".
The next obstacle is - you wouldn't believe it - the correct use of case-sensitive parameters in the querystring. So much to say for case-insensitiveness of querystring-parameters.
Use this code-snippet to redirect to a PublishingPage:
PublishingPage newPage = <Method that creates
thePublishingPage>();
...
newPage.CheckOut();
string controlMode = "Edit";
string displayMode = "Design";
Page.Response.Redirect(string.Format("{0}?ControlMode={1}&DisplayMode={2}", newPage.Uri.AbsoluteUri, controlMode, displayMode), true);
Be sure to write "Edit" and "Design" with capitalized letters or else it wouldn't work.
Keine Kommentare:
Kommentar veröffentlichen