开发者

master page implementation in asp.net

开发者 https://www.devze.com 2023-03-09 02:12 出处:网络
i am using vb-2008 to create my application. i created master page in asp but i am not able to use it on other pages. i used :

i am using vb-2008 to create my application. i created master page in asp but i am not able to use it on other pages. i used :

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" MasterPageFile="~/Mail.Master" Inherits="webform1._Default" %>

i created master page as:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Mail.master.cs" Inherits="master1.Mail" %>

<!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>Untitled Page</title>
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="MainContent" runat="server">
        <asp:Image ID="imghead" runat="server" ImageUrl="~/images/images1.jpeg" />
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

but this is not showing master page on other page where it is imp开发者_StackOverflow中文版lemented.. how can i implement the master page..


Now you need to create ASPX pages that have the masterpage assigned and fill up the content placeholders

your new page called, for example, default.aspx will contain:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" MasterPageFile="~/Mail.Master" Inherits="webform1._Default" %>

<asp:ContentPlaceHolder ID="HeadContent" runat="server">
    <!-- Add code here to add to the HeadContent section -->
</asp:ContentPlaceHolder>

<asp:ContentPlaceHolder ID="MainContent" runat="server">
    <!-- Add code here to add to the MainContent section -->
    <asp:Image ID="imghead" runat="server" ImageUrl="~/images/images1.jpeg" />
</asp:ContentPlaceHolder>

A MasterPage only holds the PlaceHolders for where other pages will inject content.

There is a hole Video on MasterPages that you can see here:

ASP.NET WebForms Part 5: MasterPages

0

精彩评论

暂无评论...
验证码 换一张
取 消