Hi, I'm back again... I'm trying this simple sample app I created and can't get it to work...
I have page1 with 2 textboxes inside an updatepanel. Upon clicking a button outside of the updatepanel (which has a trigger to cause an async postback), it goes to page2 with simply 2 textboxes on it that now contain the values from page1.
When I click the browsers Back button, I'm expecting the History.Navigate method to hit my breakpoint to restore the state, but it never gets there.
I'm watching the following video (http://video.msn.com/video.aspx?mkt=en-us&tab=soapbox&vid=0c4b85ad-9ee8-460d-84db-65fa13e8e52f) which I noticed 4:58 into the video that he appears to be using VS2008 and the ScriptManager control has a property called "EnableHistory". This was what appeared to be missing since the default property is False (ie it wasn't hitting the OnNavigate method of the Scriptmanager control). However, when I look at the same Scriptmanager control in my VS2005 project, I don't see the "EnableHistory" property at all! I even went to html view and started typing for some intellisense, and the property still didn't show up.
Here is my html code on Page1.aspx:
<code>
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="History1" EventName="Navigate" />
</Triggers>
</asp:UpdatePanel>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
<br />
<br />
<asp:History ID="History1" runat="server">
</asp:History>
<br />
</div>
</form>
</body>
</html>
</code>
Here is my code-behind file for Page1.aspx:
<code>
Partial Class _Default
Inherits System.Web.UI.Page
Private cls1 As Class1
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
cls1 = New Class1
cls1.Text1 = TextBox1.Text
cls1.Text2 = TextBox2.Text
History1.AddHistoryPoint("search", cls1)
cls1 = Nothing
Response.Redirect("page3.aspx?Text1=" & TextBox1.Text & "&Text2=" & TextBox2.Text)
End Sub
Private Sub History1_Navigate(ByVal sender As Object, ByVal args As Microsoft.Web.Preview.UI.Controls.HistoryEventArgs) Handles History1.Navigate
If (args.State.ContainsKey("search")) Then
cls1 = New Class1
cls1 = DirectCast(args.State("search"), Class1)
TextBox1.Text = cls1.Text1
TextBox2.Text = cls1.Text2
End If
End Sub
End Class
</code>
Note that I left out the Class1.vb class in the App_Code directory for brevity.
Step2.aspx simply has two textboxes on it (no updatepanel or other ajax controls).
Like I said, the History.Navigate method is not being hit and the controls on page1 are not being restored. I believe I have set this up properly. Could somebody please tell me what I might be missing?
Thanks so much in advance...