History control

Last post 04-27-2008 10:03 AM by nomadsolo. 19 replies.

Sort Posts:

  • Re: History control

    01-24-2008, 1:42 PM
    • Loading...
    • wsyeager
    • Joined on 06-26-2002, 7:42 PM
    • Weston, Florida, USA
    • Posts 435

    If that's the case, how does history work in VS 2008 when the user presses the 'Back' button?

    Thanks,

    Bill Yeager MCP.Net, BCIP
  • Re: History control

    01-29-2008, 12:26 AM
    • Loading...
    • goodbox
    • Joined on 01-22-2008, 5:04 AM
    • boulder, co
    • Posts 15

    hey, i read through this post and i gotta say that it was very helpful. using an object to store history state definitely gives you the ability to store a morecomplex state than just an index, as is shown in the docs for the extensions. i am having an issue with my application though, that hopefully one of you guys can answer.

    i have a masterpage with a scriptmanager in it, and a page  with a wizard that uses the masterpage/scriptmanager. for some reason, the history feature isn't working right. theres an extra back step in the history when i click back in the wizard and when i click it i get the error

    System.ArgumentException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. 

    at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument)
       at System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument)
       at System.Web.UI.WebControls.TextBox.LoadPostData(String postDataKey, NameValueCollection postCollection)

    when i put the scriptmanager in the actual page and not in the masterpage, it works fine.

    any help would be appreciated.

  • Re: History control

    02-15-2008, 3:45 PM
    • Loading...
    • wsyeager
    • Joined on 06-26-2002, 7:42 PM
    • Weston, Florida, USA
    • Posts 435

    Both these options are valid depending upon the situation with what you want to capture in history (A couple of items or a whole page full of form items).

    I'm disappointed that while the ASP.Net Ajax control toolkit is great, there should be a much simpler control for handling history. Better yet, it somehow should be built into the browser like it is without using Ajax.

    It's a lot of work on the programmers part to keep track of this for every page a user visits. Typically, entire pages must be restored to their previous state when a user clicks the Back button. That could add up to a lot of form data. After all, what good is using Ajax if it can't restore state? The Back button is the most commonloy used button on browsers. I just find it taking up a lot of development time. While not using Ajax, we didn't have to worry about restoring state. The browser did it automatically (and yes, I know why Ajax does this just by the nature of asynchronus postbacks).

    btw, does Ajax work inside IFrames?

    Thanks,

    Bill Yeager MCP.Net, BCIP
  • Re: History control

    02-16-2008, 5:58 PM
    • Loading...
    • wsyeager
    • Joined on 06-26-2002, 7:42 PM
    • Weston, Florida, USA
    • Posts 435

    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 />
                &nbsp;</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...

    Thanks,

    Bill Yeager MCP.Net, BCIP
  • Re: History control

    04-27-2008, 10:03 AM
    • Loading...
    • nomadsolo
    • Joined on 11-07-2007, 3:58 PM
    • Posts 34

     Regarding your not seeing the scriptmanager.enablehistory property etc. that Bertrand describes I suspect the problem is that your app is not referencing the newest release of ajax extensions (which replaces the history control with scriptmanager functionality). Unless you are using the newest extension release website template, you will have to change all of your web.config references for System.Web.Extensions from Version=3.5.0.0 to Version=3.6.0.0. It gets very complicated with the redirect elements in that file so I strongly suggest you take a look at the web.config from a ajax website template app where the System.Web.Extensions are 3.6

Page 2 of 2 (20 items) < Previous 1 2