Skip to content

Instantly share code, notes, and snippets.

@masaru-b-cl
Created June 21, 2012 04:25
Show Gist options
  • Save masaru-b-cl/2963825 to your computer and use it in GitHub Desktop.
Save masaru-b-cl/2963825 to your computer and use it in GitHub Desktop.
Survey
<browsers>
<browser refID="Default">
<controlAdapters>
<adapter controlType="System.Web.UI.Page" adapterType="Navigation.StateAdapter, Navigation" />
</controlAdapters>
</browser>
</browsers>
..\..\Documents\Visual Studio 2010\Projects\SampleNavigationSite\packages\Navigation.1.4\lib\4.0\Navigation.dll
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Navigation" version="1.4" />
</packages>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Question1.aspx.cs" Inherits="Question1" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<h1>
Question 1</h1>
<h2>
Which ASP.NET technology are you currently using?</h2>
<asp:RadioButtonList ID="Answer" runat="server">
<asp:ListItem Text="Web Forms" Selected="True" />
<asp:ListItem Text="MVC" />
</asp:RadioButtonList>
<asp:Button ID="Next" runat="server" Text="Next" onclick="Next_Click" />
</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 Navigation;
public partial class Question1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (StateContext.Data["answer"] != null)
{
Answer.SelectedValue = StateContext.Data["answer"] as string;
}
}
}
protected void Next_Click(object sender, EventArgs e)
{
StateContext.Data["answer"] = Answer.SelectedValue;
var data = new NavigationData();
data["technology"] = Answer.SelectedValue;
if (Answer.SelectedValue != "MVC")
{
StateController.Navigate("Next", data);
}
else
{
StateController.Navigate("Next_MVC", data);
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Question2.aspx.cs" Inherits="Question2" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<h1>
Question 1</h1>
<asp:HyperLink ID="Question1" runat="server" Text="Question 1" />
<h2>
Are you using the Navigation for ASP.NET Web Forms framework?</h2>
<asp:RadioButtonList ID="Answer" runat="server">
<asp:ListItem Text="Yes" />
<asp:ListItem Text="No" />
</asp:RadioButtonList>
<asp:Button ID="Next" runat="server" Text="Next" OnClick="Next_Click" />
</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 Navigation;
public partial class Question2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Question1.NavigateUrl = StateController.GetNavigationBackLink(1);
}
protected void Next_Click(object sender, EventArgs e)
{
var data = new NavigationData(true);
data["navigation"] = Answer.SelectedValue == "Yes";
StateController.Navigate("Next", data);
}
}
<StateInfo>
<dialog key="Survey" initial="Question1" path="~/Question1.aspx">
<state key="Question1" page="~/Question1.aspx">
<transition key="Next" to="Question2" />
<transition key="Next_MVC" to="Thanks" />
</state>
<state key="Question2" page="~/Question2.aspx">
<transition key="Next" to="Thanks" />
</state>
<state key="Thanks" page="~/Thanks.aspx">
</state>
</dialog>
</StateInfo>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Thanks.aspx.cs" Inherits="Thanks" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<h1>
Thanks</h1>
<asp:HyperLink ID="Question1" runat="server" Text="Question 1" />
<asp:HyperLink ID="Question2" runat="server" Text="Question 2" />
<h2>
Answers</h2>
<asp:Label ID="Summary" runat="server" />
</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 Navigation;
public partial class Thanks : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Summary.Text = StateContext.Data["technology"] as string;
if(StateContext.Data["navigation"] != null)
{
Summary.Text += ", " + (bool)StateContext.Data["navigation"];
}
if (StateController.CanNavigateBack(2))
{
Question1.NavigateUrl = StateController.GetNavigationBackLink(2);
Question2.NavigateUrl = StateController.GetNavigationBackLink(1);
}
else
{
Question1.NavigateUrl = StateController.GetNavigationBackLink(1);
Question2.Visible = false;
}
}
}
<?xml version="1.0"?>
<!--
ASP.NET アプリケーションを構成する方法の詳細については、
http://go.microsoft.com/fwlink/?LinkId=169433 を参照してください
-->
<configuration>
<configSections>
<sectionGroup name="Navigation">
<section name="StateInfo" type="Navigation.StateInfoSectionHandler, Navigation"/>
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0">
<expressionBuilders>
<add expressionPrefix="NavigationData" type="Navigation.NavigationDataExpressionBuilder, Navigation"/>
</expressionBuilders>
</compilation>
</system.web>
<Navigation>
<StateInfo configSource="StateInfo.config"/>
</Navigation>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment