Free Jobs
Reference




Dot Net Forums: ASPNET (77) C#.NET (39) VB.NET (8) AJAX (21) Silver Light (1) WCF (10) WPF (1) WWF (1) .NET 3.5 (3) SQL SERVER (38) Other (3)

Topic: What are the different ways to set MasterPage of a page in ASP.NET

To get the Posted Questions details daily in your mail Click Here

Share this Post on Facebook/Twitter/Orkut Bookmark and Share





User: dhiraj5079 Post Date: 11 Feb 2012 02:01

Introduction:
What are the different ways to set MasterPage of a page in ASP.NET



Main Content:


  a)Set in the Page Directive at the Top of the Page as below:



     <%@ Page Language="C#" MasterPageFile="~/Master1.master"

  b)We can set the master page programmetically as below:



    void Page_PreInit(object sender, EventArgs e)

    {

        MasterPageFile = "~/SiteMaster.master";

    }



  c)Create a Http Module and inside that module

    set the master page as below:

    void page_PreInit(object sender, EventArgs e)

    {

        Page page = sender as Page;

        if (page != null)

        {

            page.MasterPageFile = "~/SiteMaster.master";

        }

    }



Conclusion:
These are the three ways to set the MasterPage of a Page



About Writer:
Hi,I am IT Professional From Mumbai


Writer's Link: http://

Writer's Email:







Comments:
Post Comment





Similar Articles Top ArticlesLatest Articles Other Articles by this Author







www.freejobsreference.com Copyright © 2009-2011 | All Rights Reserved
All content of this website is protected by copyright laws and should not be reproduced in any form or by any means without written permission
(Best viewed in IE 8.0+ or Firefox 3.0+ at resolution of 1024 * 768 or higher)