From any given State the permissible Navigations are following any child Transition or jumping to another Dialog. Navigating along a Transition will move to the State referred to in the ‘to’ attribute of the Transition and so will always remain within the same
Dialog. Navigating to another Dialog will move to the State referred to in the ‘initial’ attribute. Both these are considered forward Navigations.
Taking the State Information configured in
as an example, The image below shows the possible Navigations between States. An example route taken by the user could be starting at Dialog, D1, and Navigating along Transition T1 and then to Dialog D2 and described by:
D1-S1 -> D1-S2 -> D2-S1
A stopping point in the above route is a State but it is represented by the ‘Dialog key - State key’ combination as this is unique, whereas the ‘State key’ alone is not.
Possible Navigations between States
The StateController class provides methods, called Navigate and GetNavigationLink, to perform these forward Navigations. Both these methods require an action parameter that must take one of the following values as read from the
- Transition key – this must be the key of one of the child Transitions of the current State
- Dialog key – this can be the key of any Dialog
So, in the example route above these action parameters would be D1, T1 and D2.
The three different ways to move between aspx Pages in ASP.NET are:
- Redirect – a call is made from the Server to Response.Redirect passing a URL. This transfers control to the browser which issues a call for this URL
- Transfer – a call is made from the Server to Server.Transfer passing a URL. Control stays on the Server and ASP.NET ends processing of the current Page and starts processing the Page specified in the URL
The Navigation Framework StateController methods cater for each of these different types. For Redirecting and Transferring the method required is Navigate, an overload of which accepts a NavigationMode parameter which specifies whether to Redirect or Transfer
(the default is Redirect); and for a Hyperlink the method is GetNavigationLink.
The StateContext class tracks the current and previous State in its State and PreviousState properties. In the example route, when the State is D2-S1 the PreviousState would be D1-S2. These properties are not strings but point to the
elements read from configuration and contained in the Dialogs property of the StateInfoConfig class.
Sample Web Site
The second page of the NavigationSample Web Site will display the details of a person selected from the list, so begin by adding a Web Form called Details.aspx to the Web Project. In order to navigate from the Listing.aspx to Details.aspx the StateInfo.config
must be amended with the addition of a new Details State and Transition below the Listing State pointing at this State, as shown below.
<dialog key="Person" initial="Listing" path="~/Listing.aspx">
<state key="Listing" page="~/Listing.aspx" title="Person Search">
<transition key="Select" to="Details"/>
<state key="Details" page="~/Details.aspx" title="Person Details">
Change the Search method to construct a URL using this Transition key and then return it in a Link property, as shown below, making sure to add a using to the Navigation namespace.
public IEnumerable Search()
return from p in _People
Link = StateController.GetNavigationLink("Select")
The BoundField Name column of Listing.aspx can be changed to a TemplateField containing a HyperLink with its NavigateUrl property databound to the Link property, as shown below. For the time being the old DataBinding syntax, Eval, will be used, rather than
the strongly-typed syntax introduced in VS 2012. This is because returning an anonymous type from the Search method prohibits its use, but in the
section this will be rectified.
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Link") %>' Text='<%#: Eval("Name") %>' />
Pressing F5 will display the table of three people with the first column containing a Hyperlink, clicking this link will display the blank Details.aspx Page. This is an example of navigating passing a Transition key as the action parameter to the StateController.
The navigation results in the Details State because it is configured as the 'to' State of the Select Transition
The other type of navigation, where a Dialog key is passed, will be used to go from the Details.aspx Page back to Listing.aspx. To Details.aspx add a Button together with a Button Click handler (see below); in later sections this will be changed to a Hyperlink,
but a button is used here to demonstrate the different types of Navigation.
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Listing" OnClick="Button1_Click" />
To the Click handler add the code shown below, making sure to add a using to the Navigation namespace. The uncommented line results in a Response Redirect whereas the commented line results in a Server Transfer. Pressing F5 and clicking the Hyperlink will display
the Details.aspx Page; clicking the Button on this page will display the Listing.aspx Page. The navigation results in the Listing State because it is configured as the 'initial' State of the Person Dialog.
protected void Button1_Click(object sender, EventArgs e)