Fixed and closed #416: browser properly navigates to edited header when editing a section. Cancel also preserves the position in the page.

This commit is contained in:
Dario Solera 2009-12-15 17:00:53 +00:00
parent 8103eb6e9b
commit 7b5d3223b3
2 changed files with 13 additions and 4 deletions

View file

@ -16,5 +16,5 @@ using System.Reflection;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("3.0.1.444")] [assembly: AssemblyVersion("3.0.1.445")]
[assembly: AssemblyFileVersion("3.0.1.444")] [assembly: AssemblyFileVersion("3.0.1.445")]

View file

@ -427,7 +427,16 @@ namespace ScrewTurn.Wiki {
protected void btnCancel_Click(object sender, EventArgs e) { protected void btnCancel_Click(object sender, EventArgs e) {
if(currentPage == null && txtName.Visible) currentPage = Pages.FindPage(NameTools.GetFullName(DetectNamespace(), txtName.Text)); 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")); else UrlTools.Redirect(UrlTools.BuildUrl("Default.aspx"));
} }
@ -653,7 +662,7 @@ namespace ScrewTurn.Wiki {
if(redirect) { if(redirect) {
Collisions.CancelEditingSession(currentPage, username); Collisions.CancelEditingSession(currentPage, username);
string target = UrlTools.BuildUrl(Tools.UrlEncode(currentPage.FullName), Settings.PageExtension, "?NoRedirect=1", 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); UrlTools.Redirect(target);
} }
} }