navigation - ASP.NET Back Button for multiple forms -
i trying track navigation between number of web forms in asp.net. i've tried client side navigation using following:
<asp:button id="backbutton" runat="server" text="back" onclientclick="javascript:window.history.back(1);return false;" />
unfortunately not work scenario due postbacks going on. scenario has number of web forms:
- page1.1
- page1.2
- page2
- page3
navigating forward through pages works wizard. there 2 starting points - page1.1 , page1.2.
page1.1 -> page2 -> page3
page1.2 -> page2 -> page3
so clicking buttons have following navigation:
page3 -> page2
page2 -> page1.1
page2 -> page1.2
there additional parameters passed between pages need maintained.
i looking @ maintaining in session maintain current call stack works however, getting build of referrer urls. @ minute trying conceptualise this.
i running in sharepoint application pages, each page asp.net page sake of example.
so have introduced abstract class each page:
public abstract class securelayoutspagebase : system.web.ui.page { private pagecontroller _pagecontroller; protected override void onload(eventargs e) { base.onload(e); _pagecontroller = (pagecontroller)session["pagecontroller"]; if (_pagecontroller == null) { _pagecontroller = new pagecontroller(); session["pagecontroller"] = _pagecontroller; } if (!page.ispostback && page.request.urlreferrer != null) { this.pagecontroller.history.push(page.request.urlreferrer.tostring()); } } protected pagecontroller pagecontroller { { return _pagecontroller; } } }
which has instance of pagecontroller:
[serializable()] public class pagecontroller { private stack<string> _history = new stack<string>(); public void previous(httpresponse response) { string previous = _history.pop(); response.redirect(previous); } public stack<string> history { { return _history; } } }
then each page call pagecontroller.previous in server side event handler button click:
protected void backbutton_click(object sender, eventargs e) { this.pagecontroller.previous(this.response); }
this issue calling pagecontroller.previous still results in url being added stack. wondering if there way prevent url getting added when has been clicked. or alternative solutions...
history(-1) wont work, because include postbacks. set button href dependant on whatever page you're on. if know itsloaded page 3, set button page 2
Comments
Post a Comment