ASP.NET Podcast Show #117 - Using the History Functionality with the ASP.NET AJAX UpdatePanel in .NET 3.5 Service Pack 1 Beta 1 - More Wally - Wallace B. McClure
in

MoreWally.com

Giving people what they want, More Wally. This is the technical and personal blog site of
Wallace B. (Wally) McClure.

This Blog

Syndication

Technical Sites

More Wally - Wallace B. McClure

This blog will have all kinds of posts about Wally McClure. In it, there will be tons of .NET and computer programming posts as well as Wally's views on life in general. As you might guess, this site and blog help you get More Wally in your life. What more could anyone want? .NET, ADO.NET, ASP.NET, AJAX, Atlas, Microsoft AJAX Library, ASP.NET 2.0 AJAX Extensions, ............

ASP.NET Podcast Show #117 - Using the History Functionality with the ASP.NET AJAX UpdatePanel in .NET 3.5 Service Pack 1 Beta 1

Subscriptions & Downloads

Subscribe to everything.

Back to the original url on the ASP.NET Podcast site

Subscribe to WMV.

Subscribe to M4V for iPod.

Subscribe to MP3.

Download WMV.

Download M4V for iPod.

Download MP3.

Show Notes:

Images:

This is the UpdatePanel with EnableSecureHistoryState set to true

EnableSecureHistoryState=true 

This is the UpdatePanel with EnableSecureHistoryState set to false.

 EnableSecureHistoryState=false

Source Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UpdatePanelHistory.aspx.cs" Inherits="UpdatePanelHistory" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>UpdatePanel History Button</title>

</head>

<body>

    <form id="form1" runat="server">

    <asp:ScriptManager ID="scm" runat="server"

       EnableHistory="true"

       OnNavigate="scm_Navigate"

       />

    <div>

    <asp:Button ID="btnSubmit" runat="server" Text="Click Me!"

            onclick="btnSubmit_Click" />

    <asp:UpdatePanel ID="upl" runat="server" UpdateMode="Conditional">

    <ContentTemplate>

        <asp:Label ID="lblTime" runat="server" />

    </ContentTemplate>

    <Triggers>

        <asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />

    </Triggers>

    </asp:UpdatePanel>

    </div>

    </form>

</body>

</html>

 

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Collections.Specialized;

public partial class UpdatePanelHistory : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

 

    protected void scm_Navigate(object sender, HistoryEventArgs he)

    {

        NameValueCollection pageState = he.State;

        string dtS;

        if (pageState != null)

        {

            dtS = pageState.Get("Time");

            if (!String.IsNullOrEmpty(dtS))

            {

                lblTime.Text = dtS;

            }

            else

            {

                lblTime.Text = String.Empty;

            }

            upl.Update();

        }

    }

 

    protected void btnSubmit_Click(object sender, EventArgs e)

    {

        string dtS = DateTime.Now.ToString();

        lblTime.Text = dtS;

        if ((scm.IsInAsyncPostBack == true) && (scm.IsNavigating != true))

        {

            AddHistoryPoint(dtS);

        }

    }

    private void AddHistoryPoint(string HistoryPoint)

    {

        NameValueCollection pageState = new NameValueCollection();

        pageState.Add("Time", HistoryPoint);

        scm.AddHistoryPoint(pageState, "Time:" + HistoryPoint);

    }

}

 

Comments

No Comments

About wallym

Wallace B. (Wally) McClure INETA Speaker's Bureau Microsoft MVP ASPInsider Co-author of "Beginning AJAX with ASP.NET" Co-author of "Professional ADO.NET Programming" Co-author of "Building Highly Scalable Database Applications with .NET" Master's Degree in Electrical Engineering from Georgia Tech Bachelor's Degree in Electrical Engineering from Georgia Tech
2006 - Wallace B. McClure
Powered by Community Server (Non-Commercial Edition), by Telligent Systems