From 7b5d3223b387ca95a1052014c8e87f160a8453d3 Mon Sep 17 00:00:00 2001 From: Dario Solera Date: Tue, 15 Dec 2009 17:00:53 +0000 Subject: [PATCH] Fixed and closed #416: browser properly navigates to edited header when editing a section. Cancel also preserves the position in the page. --- AssemblyVersion.cs | 4 ++-- WebApplication/Edit.aspx.cs | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/AssemblyVersion.cs b/AssemblyVersion.cs index 41a01a7..21cc6b6 100644 --- a/AssemblyVersion.cs +++ b/AssemblyVersion.cs @@ -16,5 +16,5 @@ using System.Reflection; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.0.1.444")] -[assembly: AssemblyFileVersion("3.0.1.444")] +[assembly: AssemblyVersion("3.0.1.445")] +[assembly: AssemblyFileVersion("3.0.1.445")] diff --git a/WebApplication/Edit.aspx.cs b/WebApplication/Edit.aspx.cs index da048ac..b451aa0 100644 --- a/WebApplication/Edit.aspx.cs +++ b/WebApplication/Edit.aspx.cs @@ -427,7 +427,16 @@ namespace ScrewTurn.Wiki { protected void btnCancel_Click(object sender, EventArgs e) { if(currentPage == null && txtName.Visible) currentPage = Pages.FindPage(NameTools.GetFullName(DetectNamespace(), txtName.Text)); - if(currentPage != null) UrlTools.Redirect(Tools.UrlEncode(currentPage.FullName) + Settings.PageExtension); + if(currentPage != null) { + // Try redirecting to proper section + string anchor = null; + if(currentSection != -1) { + int start, len; + ExtractSection(Content.GetPageContent(currentPage, true).Content, currentSection, out start, out len, out anchor); + } + + UrlTools.Redirect(Tools.UrlEncode(currentPage.FullName) + Settings.PageExtension + (anchor != null ? ("#" + anchor + "_" + currentSection.ToString()) : "")); + } else UrlTools.Redirect(UrlTools.BuildUrl("Default.aspx")); } @@ -653,7 +662,7 @@ namespace ScrewTurn.Wiki { if(redirect) { Collisions.CancelEditingSession(currentPage, username); string target = UrlTools.BuildUrl(Tools.UrlEncode(currentPage.FullName), Settings.PageExtension, "?NoRedirect=1", - (!string.IsNullOrEmpty(anchor) ? ("#" + anchor) : "")); + (!string.IsNullOrEmpty(anchor) ? ("#" + anchor + "_" + currentSection.ToString()) : "")); UrlTools.Redirect(target); } }