protected new void CreateButton_Click(object sender, EventArgs e) { if (Page.IsValid) { SPLongOperation.Begin(delegate(SPLongOperation longOperation) { SPWeb web = SPContext.Current.Web; PublishingWeb currentPublishingWeb = PublishingWeb.GetPublishingWeb(web); PublishingPage publishingPage = null; SPFolder sPFolder = null; if (!string.IsNullOrEmpty(folderUrl)) { sPFolder = currentPublishingWeb.Web.GetFolder(folderUrl); if (!sPFolder.Exists) { string url = Helper.ConcatUrls(folderUrl, nameInput.Text); SPUtility.CreateParentFoldersForFile(currentPublishingWeb.PagesList, url, false); sPFolder = currentPublishingWeb.Web.GetFolder(folderUrl); } } PageLayout pageLayout = null; string text = base.Request.QueryString.Get("PLUrl"); if (string.IsNullOrEmpty(text)) { pageLayout = currentPublishingWeb.DefaultPageLayout; } else { try { pageLayout = new PageLayout(base.Web.GetListItem(text)); } catch (Exception) { Logger.ToLog(new Exception(string.Format("Unable to create PageLayout from listitem of path : {0}", text))); pageLayout = currentPublishingWeb.DefaultPageLayout; } } publishingPage = SPHelper.CreatePublishingPage(currentPublishingWeb, nameInput.Text, pageLayout, sPFolder, false); if (publishingPage != null && originalRequestedName != null) { publishingPage.Title = originalRequestedName; publishingPage.ListItem["NewsType"] = ddlNewsType.SelectedValue; publishingPage.Update(); } string text2 = SPHttpUtility.UrlPathEncode(publishingPage.ListItem.File.ServerRelativeUrl, false); string FinishUrl = SPHelper.DesignModeUrl(text2); if (!string.IsNullOrEmpty(base.Request.QueryString.Get("IsDlg"))) { if (base.Request.QueryString["shouldRedirectPage"] == "0") { string scriptLiteralToEncode = SPHelper.ConvertToAbsoluteUrl(FinishUrl, currentPublishingWeb.Web.Site, true); longOperation.EndScript("window.frameElement.commitPopup('" + SPHttpUtility.EcmaScriptStringLiteralEncode(scriptLiteralToEncode) + "');"); } else { longOperation.EndScript("window.frameElement.navigateParent('" + SPHttpUtility.EcmaScriptStringLiteralEncode(FinishUrl) + "');"); } } else { longOperation.End(FinishUrl); } }); } }