Posts

Creating Master Page (Nested Master Page) in ASP.NET Part 3

Image
Introduction If we are building a large website, we might need to create multiple levels of Master Pages. For example, we might want to create a single site-wide Master Page that applies to all the content pages in our website. In addition, we might need to create multiple section-wide Master Pages that apply to only the pages contained in a particular section. Remember, we can not work with nested Master Pages in Visual Web Developer or Visual Studio 2005 or earlier while in Design view. If we need to nest Master Pages, then we need to stick to Source view. We can nest Master Pages as many levels as we need. For example the code given below contains a Master Page named Site_Main.master, which displays a logo image and contains a single content area. It also contains site-wide navigation links. <% @   Master   Language ="VB"   CodeFile ="Site_Main.master.vb" Inherits ="MasterPage"   %> <! DOCTYPE   html   PUBLIC   "-//W3C//DTD XHTM...

Creating Master Page (Using Images and Hyperlinks) in ASP.NET Part 4

Image
Introduction We must be careful when using relative URLs in a Master Page. For example, we must be careful when adding images and links to a Master Page. Relative URLs are interpreted in different ways, depending on whether they are used with HTML tags or ASP.NET controls. If we use a relative URL with an ASP.NET control, then the URL is interpreted relative to the Master Page. For example, suppose that we add the following ASP.NET Image control to a Master Page: < asp : Image   ID ="Image1"   runat ="server" ImageUrl ="~/Images/CSSiteLogo.gif"   /> The ImageUrl property contains a relative URL. If the Master Page is located in a folder named MasterPages, then the URL is interpreted like this: /MasterPages/CSSiteLogo.gif" Even if a content page is located in a completely different folder, the ImageUrl is interpreted relative to the folder that contains the Master Page and not relative to the co...

Creating Master Page (MasterPage in Web.config) in ASP.NET Part 5

Introduction on   Web.config   Master Page Setting We   can apply a Master Page to every content page in a particular folder or every content page in an entire application. Rather than add a   MasterPageFile   attribute to individual content pages, we can add a configuration option to the web configuration file. For example, the web configuration file given below applies the   SimpleMaster.master   Master Page to every page contained in the same folder (or subfolder) as the web configuration file. <? xml   version = " 1.0 " ?> < configuration >   < system.web >     < pages   masterPageFile = " ~/ MasterPage.master "   />   </ system.web > </ configuration > Above Master Page given in   Web.config   file is applied only to content pages. If a page does not contain any Content controls it is a normal ASP.NET page then the Master Page is ignored. We can ov...

Popular posts from this blog

Migrating database from ASP.NET Identity to ASP.NET Core Identity

Customize User's Profile in ASP.NET Identity System