About ASP. NET Dynamic Loading master page

Source: Internet
Author: User
Code

// About ASP. NET Dynamic Loading master page
// First create a master page Master. Master
/*
<% @ Master language = "C #" autoeventwireup = "true" codefile = "Master. Master. cs" inherits = "master" %>

<! 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 ">
<Head runat = "server">
<Title> </title>
<Asp: contentplaceholder id = "head" runat = "server">
</ASP: contentplaceholder>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Span> master is using... </span>
<Asp: contentplaceholder id = "contentplaceholder1" runat = "server">

</ASP: contentplaceholder>
</Div>
</Form>
</Body>
</Html>
*/
// Create a content page and remove all HTML
<% @ Page Language = " C # " Autoeventwireup = " True " Codefile = " Default2.aspx. CS " Inherits = " Default2 "   %>
< ASP: Content runat = " Server " ID = " CT " Contentplaceholderid = " Contentplaceholder1 " >
< ASP: Label runat = " Server " ID = " Dd " > This Is A Test !! </ ASP: Label >
</ ASP: Content >
// Create a basic page
///   <Summary>
/// Basepage Summary
///   </Summary>
Public   Class Basepage: system. Web. UI. Page
{
Public Basepage ()
{
//
// Todo: add the constructor logic here
//
This . Preinit + =   New Eventhandler (basepage_preinit );
}
// The loading of the motherboard page is in the preinit event.
Void Basepage_preinit ( Object Sender, eventargs E)
{
Masterpagefile =   " ~ /Master. Master " ;
}
}
// Finally, inherit the base class from the class on the Content Page.
Public   Partial   Class Default2: basepage
{
Protected   Void Page_load ( Object Sender, eventargs E)
{

}
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.