We all are quite familiar with the Back and Forward buttons of a web browser. They work exactly as they should, but when dealing with server-side pages that take advantage of post-backs, such as ASP.NET pages, the Back and Forward buttons work a little too well.
For instance, if you were to interact with a drop down list on a page or any type of control that automatically displays results to the same page, then the previous state before the change took place will be added into the browser's memory.
So in this case, what happens when you click the Back button?
That's right, you get the previous state of that page and not the actual page that you browsed from or were sent from.
ClientID property found in all ASP.NET web-controls since it knows what the rendered ID will be.
<title>Backward Forward Example</title>
var spy = null;
var refreshes = new Number(0);
var offset = new Number(1);
spy = document.getElementById(oSpyID);
refreshes = new Number(spy.value) + offset;
HyperLink controls and one
input server tag (the post-back spy). Note that if you want a more graphical look, you can wrap these
HyperLink controls around backward and forward images.
<asp:HyperLink CssClass="navPages" ID="hpBackward" Runat="server">
<img src="../images/nav-arrow-backward.gif" /></asp:HyperLink>
<asp:HyperLink CssClass="navPages" ID="hpForward" Runat="server">
<img src="../images/nav-arrow-forward.gif" /></asp:HyperLink>
<input type="hidden" id="inputPostBackSpy" runat="server" />
In the code-behind file or in the server script tags, declare the
HyperLinks and set their attributes respectfully.
Protected WithEvents inputPostBackSpy As HtmlInputHidden
Protected WithEvents hpBackward As HyperLink
Protected WithEvents hpForward As HyperLink
Private Property PostBackSpy() As Integer
Set(ByVal Value As Integer)
inputPostBackSpy.Value = Value.ToString()
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not Me.IsPostBack Then
"Backward('" & inputPostBackSpy.ClientID & "')")
PostBackSpy = 0
PostBackSpy = PostBackSpy + 1
That's all there is to it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.