如何将内容占位符作为框架 [英] how to make content placeholder as frame

查看:69
本文介绍了如何将内容占位符作为框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <%@     Master    语言  =   C#    AutoEventWireup   =  true    CodeFile   =  Site.master.cs   继承  = 网站   %>  

< !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 = head runat = server >

< link href = Styles.css rel = stylesheet 类型 = text / css / >
< span class =code-keyword>< / head >
< body >
< 表格 id = form1 runat = 服务器 >
< div id = topContent >
< ; a href < span class =code-keyword> = Default.aspx > Master Pages Tutorials < / a >
< / div >

< div id = mainContent >
< asp:ContentPlaceHolder id = 主要内容 runat = server / >
< / div >

< div id = leftContent >
< p style = text-align:center; >
< asp:标签 ID = DateDispl ay runat = server / >
< / p >

< h3 > 课程< / h3 >
< ul >
< li > TODO < / li >
< / ul >

< h3 > 新闻< span class =code-keyword><
/ h3 >
< ul >
< li > TODO < / li >
< / ul
>
< / div >

< div id = footerContent >
< img src = Images / PoweredByASPNET.gif alt = 由ASP.NET提供支持! / >
< / div >
< / form >
< / body >
< / html >





在此页面我想要在内容占位符中打开单独的aspx页面

这意味着母版页的所有设计都是相同的,我只进行页面设计并在联系人位置中调用



我是新来的,所以PLZ帮助我并给出解决方案

解决方案

这不是相当正确 - 主页面没有不要调用内容页面来显示它们。相反,内容页面定义了它的主页面,以及要在内容占位符中显示的内容。



ASP.NET母版页 - MSDN [ ^ ]

关于ASP.NET中母版页的开发人员教程 [ ^ ]



 <%@       语言  =  C#    MasterPageFile   = 〜/ Site.master   标题  = 内容页面 %>  

< asp:内容 runat = server ContentPlaceholderID = head >

(标头内容在这里...)

< / asp:Content >

< asp:Content runat = server ContentPlaceholderID = 主要内容 >

(主要内容如下)这里...)

< / asp:Content >


<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>

<!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="head" runat="server">
    
    <link href="Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
        <div id="topContent">
            <a href="Default.aspx">Master Pages Tutorials</a>
        </div>
    
        <div id="mainContent">
            <asp:ContentPlaceHolder id="MainContent" runat="server" />
        </div>
        
        <div id="leftContent">
            <p style="text-align: center;">
                <asp:Label ID="DateDisplay" runat="server" />
            </p>
            
            <h3>Lessons</h3>       
            <ul>
                <li>TODO</li>
            </ul>

            <h3>News</h3>       
            <ul>
                <li>TODO</li>
            </ul>
        </div>
        
        <div id="footerContent">
            <img src="Images/PoweredByASPNET.gif" alt="Powered by ASP.NET!" />
        </div>
    </form>
</body>
</html>



In this page i want to open separate aspx page in content place holder
That means all the design of the master page will be same and I only make page design and call in contact place holder

I am new so plz help me and give solution

解决方案

That's not quite right - the master page doesn't call the content pages to display them. Instead, the content page defines its master page, and the content to display inside the content placeholders.

ASP.NET Master Pages - MSDN[^]
Beginner's Tutorial on Master Pages in ASP.NET[^]

<%@ Page Language="C#" MasterPageFile="~/Site.master" Title="Content Page"%>

<asp:Content runat="server" ContentPlaceholderID="head">

(Header content goes here...)

</asp:Content>

<asp:Content runat="server" ContentPlaceholderID="MainContent">

(Main content goes here...)

</asp:Content>


这篇关于如何将内容占位符作为框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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