asp.net中的母版页实现 [英] master page implementation in asp.net

查看:120
本文介绍了asp.net中的母版页实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用vb-2008创建我的应用程序.我在asp中创建了母版页,但是我无法在其他页面上使用它.我用过:

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" %>

我创建的母版页为:

<%@ 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 implemented.. how can i implement the master page..

推荐答案

现在,您需要创建分配了masterpage的ASPX页面并填充内容占位符

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

例如称为default.aspx的新页面将包含:

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仅保留PlaceHolders用于其他页面将在其中插入内容的位置.

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 第5部分:

ASP.NET WebForms Part 5: MasterPages

这篇关于asp.net中的母版页实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆