accept to this tutorial on Introduction To Master Pages in ASP. Net 2.0. In this tutorial I ordain furnish an overview of what know Pages are how they work and how to use one in your web application. First what is a know Page a know summon is an ASP. NET register with the extension master (for example. YourMaster know) which holds the layout and standard behavior for your entire web application. A know Page can include static text. HTML elements and ASP: server controls. Using a know Page in your ASP. Net 2.0 web application allows you to act a consistant be and conclude and layout for your web application all in a single summon. When you create your Master Page act it as if you would a template for your site desire when you first go away your site you work with a single "template" file until you get the layout be and conclude you be. object with a Master summon instead of adding all the circumscribe to a single summon you add a that will hold the circumscribe for that specified region in your application. Lets say with your application you be a header across the top then a nagvigation column with the be being the main circumscribe of your pages. Without know Pages you create the initial template for your site then write and attach that template for each and every summon you be changing the content in the main section and possible the navigation. With a Master Page you be that same layout except for the main circumscribe area you add a ContentPlaceHolder for that divide then when you add a new summon and link it to your know summon all the layout is there with the main circumscribe area alter for adding the circumscribe for that summon. When not using Master Pages you create the layout you be then write that layout to each and every page theres always going to be at least one summon where something is a single pixel off no be what you do with know Pages that is eliminated. Master Pages have revolutionized the way Web Applications and layout are done. With Master Pages you can create individual content pages that contain the content you be to on your summon then when users request that page they integrate with the know summon to create create that combines the layout of the master page with the content from the circumscribe page. It's really that simple. So lets act a be at adding a know summon to your Web Application. Open Visual Studio and create a new File System website (this is created on your local machine no be to connect to a web server). Name this whatever you be like maybe MasterPages_In_ASPNet. Once its loaded right-click on the website label and select Add Folder. I always label this folder MasterPages and it holds all my know Pages for that web application. We'll get to why you might have more than one before this tutorial is over. Now right-click on the Masterpages folder and select Add New Item. When the Add New Item dialog opens decide know summon from the enumerate desire this
<%@ know Language="VB" CodeFile="MasterPage master vb" Inherits="Master_Pages_MasterPage" %><!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" ><continue runat="server"> <title>Untitled Page</title></continue><body> <create id="create1" runat="server"> <div> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </div> </form></be></html>
If you did nothing more with this Master summon you'd undergo a know Page with a hit circumscribe area. Like all other pages you can create this until you're happy with the layout. Do your look and feel act your layout. Once you undergo it the way you want it add a ContentPlaceHolder where you want different content on each summon like in my description above the main content area of the page. This gives you a hit file with all the navigation headers colors and styles for your entire place the only thing that will dress is what is inside the ContentPlaceHolders in the merging pages. Now lets see how we add a page and merge it with our Master summon. Right-click the website name and select Add New Item. Once the Add New Item Dialog opens select Web create from the enumerate. When the next dialog appears where you name the page analyse the Select know summon checkbox (also off the topic of this tutorial always alter sure the displace code in seperate register checkbox is checked) and move Add.
move on the know Pages folder we made earlier in the left hand window then in the alter transfer window all the Master Pages you undergo ordain show. Highlight the know summon you want to use and move OK. Once it adds your new summon it ordain be different than other pages you have worked with before. There ordain be no [inline]<HTML>[/inline] tag no [inline]<be>[/inline] tags as those are all contained in your Master Page. All you will have is something that resembles this
There are 2 properties in this header line than in most ASP. Net pages theres [inline]MasterPageFile="~/know_Pages/MasterPage master"[/inline] which tells the summon what know Page to integrate with and [inline]title="Untitled Page"[/inline] which is simply the title of your page that displays in the browser. Below that we have none of the normal HTML tags just this [inline]<asp:circumscribe ID="circumscribe1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"></asp:circumscribe>[/inline]which is where the circumscribe for the summon and site will lie. Now when you use a Master Page in a real environment more than likely there'll be more than just this one ContentPlaceHolder this is just for demonstration purposes. In my last place I had 3 ContentPlaceHolder's for the circumscribe of the site. Master Pages are nice. Master Pages ordain greatly simplify your life when it comes to creating web applications. Master Pages ordain quickly change state your new beat friend when creating web applications so use them. Earlier in this tutorial I mentioned having more than 1 Master Page for a place. I've done this so the user can customize the look and conclude & layout of the place based on settings they pick from a predefined set of "skins" this is saved in their user be then each measure they visit the know Page is loaded dynamically based on the skin they chose but this is a topic for a future tutorial. bequeath. know Pages can also include actual label say for starting the session setting the users session setting cookies for the user and so much more. That is the end of the Introduction To Master Pages in ASP. Net 2.0. convey you for reading and I hope you open this tutorial informative and useful.
Related article:
http://swik.net/SWiK/Dream.In.Code+Programming+Tutorials/Introduction+To+Master+Pages+in+ASP.Net+in+Visual+Basic+Tutorials/bna8n
comments | Add comment | Report as Spam
|