Download presentation
Presentation is loading. Please wait.
Published byBrian Cannon Modified over 9 years ago
1
Web Site Navigation How to get around in an ASP.NET web application 1Web Site Navigation
2
Links HTML anchor – Text ASP.NET HyperLink control – Text – Can be manipulated in the code-behind Example: aspnet/navigation/links 2Web Site Navigation
3
URL Uniform Ressource Locator Absolute URL – http://laerer.rhs.dk/andersb/ http://laerer.rhs.dk/andersb/ – Protocol://host/ressource Relative URL – Relative to the current page – /file.txt File in current folder – /subfolder/file.txt File in subfolder –../file.txt File in parent folder 3Web Site Navigation
4
Default documents URLS may lead to a folder, not a file – http://laerer.rhs.dk/andersb/ http://laerer.rhs.dk/andersb/ The web server will look for a default document in the folder Web servers can be configured to handled a list of default documents like 1.Default.aspx 2.Index.htm 3.Index.html 4.Etc. 4Web Site Navigation
5
ASP.NET navigation controls ASP.NET includes a few navigation controls – Menu – TreeView – SiteMapPath (aka. Bread crumps) – Visual studio The controls uses a logical structure of the web site defined in the file web.sitemap Example: aspnet/navigation/sitemap 5Web Site Navigation
6
Web.sitemap XML file with the logical structure of the web site – Not much help from Visual Studio to create this file 6Web Site Navigation
7
Menu Control Menu sub-items a unfolded as you hover the mouse over an item Uses the web.sitemap through a DataSource control – May also use other data sources than web.sitemap Can be styled in many different ways – Using CSS 7Web Site Navigation
8
TreeView Control Sub-trees can be collapsed / expanded by clicking Uses the web.sitemap through a DataSource control – May also use other data sources than web.sitemap Can be styled in many different ways – Using CSS 8Web Site Navigation
9
SiteMapPath Also known ad bread crumps Typically shown at the top of each page to tell the user where in the web site’s structure. Uses the file web.sitemap directly – No DataSource control used Typically included in a master page … … 9Web Site Navigation
10
Programmatic Redirection A web form usually submits data back the itself. – Sometimes you might want to go to a different page Client-side redirects – The client is responsible for the redirect. – Requires extra request/response – Can redirect to any web site Server-side redirect – The server is responsible for the redirect – No extra request/response – Can only redirect to other pages in this web site 10Web Site Navigation
11
Client-side redirects Client does the redirect ASP.NET Response object – Response.Redirect(newUrl) HTTP response: 303 moved temporarily – Response.RedirectPermanent(newUrl) HTTP response: 301 moved permanent Search engines will stop looking for the page 11Web Site Navigation
12
Server-side redirects Server does the redirect URL in browser not changed – Browser does not know about the redirect ASP.NET – Server.Transfer(url); – Server.Transfer(url?parameterName:value) Get the parameter value using Request.QueryString(parameterName) 12Web Site Navigation
13
Further readings, etc. Imar Spaanjaars Beginning ASP.NET 4 in C# and VB, Wrox 2010 – Chapter 7 Navigation, page 239-269 Bill Evjen Professional ASP.NET 4 in C# and VB, Wrox 2010 – Chapter 13 Site Navigation, page 519-567 George Shepherd Microsoft ASP.NET 4 Step by Step, Microsoft Press 2010 – Chapter 11 Web Site Navigation, page 237-256 W3Schools.com ASP.NET 2.0 – Navigation – http://www.w3schools.com/aspnet/aspnet_navigation.asp http://www.w3schools.com/aspnet/aspnet_navigation.asp Chris Peels How Do I Implements Site Navigation in ASP.NET (video) – http://www.asp.net/general/videos/how-do-i-implement-site- navigation-in-aspnet, 2007 http://www.asp.net/general/videos/how-do-i-implement-site- navigation-in-aspnet 13Web Site Navigation
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.