The most straightforward way to add the Navigation framewok to a new or existing ASP.NET Web Site or Application is to install it using NuGet by running the command Install-Package Navigation from within the Package Manager Console.
If NuGet is unavailable (prior to VS 2010) the set up can be performed manually. The first stage of this manual set up is to add reference to the Navigation.dll, which can be downloaded from http://navigation.codeplex.com/
. After (unblocking and) unzipping the download the Navigation.dll should be obtained from the folder (beneath the bin folder) that corresponds to the version of .NET in use.
The next state requires the registration of the StateAdapter class as an adapter for the Page control*. The steps to follow are:
- Add an App_Browsers folder – right click the Web Project and select Add ASP.NET Folder -> App_Browsers
- Add a .browser file to the App_Browsers folder – right click the App_Browsers folder and select Add New Item, select Browser File and give it a name
- Configure the StateAdapter class as the Page’s control adapter – paste the configuration below into the .browser file
<adapter controlType="System.Web.UI.Page" adapterType="Navigation.StateAdapter, Navigation" />
The final stage of the manual is to create a StateInfo.config file, which will be used in the next section to hold the details of the pages and navigation between these pages:
- Add a new Text File called StateInfo.config file to the Web Project
- Point the Navigation framework as this file by adding the configuration below into the Web.config file
<section name="StateInfo" type="Navigation.StateInfoSectionHandler, Navigation"/>
<!-- other config elided -->
There is a small difference between the NuGet and manual installations which will be covered in the Navigation Hyperlink and Data Expression section.
*In VS 2005 adding an adapter for a Page causes the XhtmlConformance setting to be ignored, for more information see http://connect.microsoft.com/VisualStudio/feedback/details/179365/using-a-page-adapter-causes-the-xhtmlconformance-mode-setting-to-be-ignored
Sample Web Site
Create a new Web Application project called NavigationSample, by selecting File -> New -> Project
and the ASP.NET Empty Web Application
option. Set it up to start using the Navigation framework by running the command Install-Package Navigation
from within the Package Manager Console.