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

@ -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);
}
}