母版页,如何使它们工作? [英] Master pages, how to make them work?

查看:70
本文介绍了母版页,如何使它们工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

又一个看似不直观的简单概念或者我只是

愚蠢。我已经阅读了WROX书,这个例子实际上并没有显示其他内容页面中.master页面如何链接?有点像一个关键的

点没有?


我错过了什么吗?


Rob。


PS那天我发现一本实际有用的书,而不仅仅是覆盖该主题旁边的一个

复选标记。 - 当然还有MSDN(这是一个什么样的笑话,这是我曾经见过的最糟糕的文档 - 样本?没有

链接或列出什么参数可以使用,没有。对不起,只是非常非常感到沮丧完全缺乏有用的文档,并不需要很多时间玩搜索和搜索游戏。如果我将我的代码记录为

,因为MSDN文档VS 2005很糟糕,我很久以前就失业了。

解决方案

< blockquote>来自Wrox的专业ASP.NET 2.0是我的圣经:-D自ASP 3.0以来我只是喜欢

他们的书...


....但是,回到你的问题...


如果你有相同的书,请看第252页,你会看到

他们有2个文件


MyMaster.master(主页)和

Default.aspx(默认页面)


in代码清单8.1:示例母版页(第254页)

你可以看到全MA STER PAGES的开头是:


<%@ Master ...


和清单8.3:使用Wrox的内容页面。大师(第258页)

你可以看到所有内容页面都在起始行中

<%@ ... MasterPageFile =" Wrox.master" ......即使你没有这本书也不会花b $ b,我想我已经说明了一点;-)


-

Bruno Alexandre

(葡萄牙人在K?benhanv,Danmark)

Rob R. Ainscough < RO ***** @ pacbell.net> escreveu na mensagem

新闻:%2 **************** @ TK2MSFTNGP03.phx.gbl ...

又一次简单的概念似乎不直观或我只是愚蠢。我已经阅读了WROX书,这个例子实际上并没有显示.master页面在其他内容页面中如何链接?有点关键点没有?

我错过了什么吗?

Rob。

P.S。那天我发现一本实际上有用的书,而不仅仅是覆盖该主题旁边的一个复选标记。 - 当然有MSDN(这是一个什么笑话,我曾经见过的最糟糕的文档 - 样本??没有
链接或列表可以使用什么参数,什么都没有。抱歉,只是非常感到沮丧的是完全缺乏有用的文档,这些文档并不需要花费很多时间来玩搜索和搜索游戏。如果我将我的代码记录为与MSDN文档VS 2005一样糟糕,我很久以前就失业了。



我忘了告诉你......


在你的Master.Page中,你需要至少有一个ContentPlaceHolder,

喜欢


< asp:ContentPlaceHolder id =" leftPane" runat =" ;服务器">

< / asp:ContentPlaceHolder>


因此,服务器可以获取内容页面并将实际内容放入

占位符

在你的内容页面中你需要在PlaceHolder中编写代码

控件,使用例子le上面:


< asp:Content id =" myLeftContent" ContentPlaceHolder =" leftPane"

runat =" server">


...你的html / asp.net / javascript代码: - )


< / asp:内容>


-


Bruno Alexandre

(葡萄牙人在K?benhanv,Danmark)

Rob R. Ainscough < RO ***** @ pacbell.net> escreveu na mensagem

新闻:%2 **************** @ TK2MSFTNGP03.phx.gbl ...

又一次简单的概念似乎不直观或我只是愚蠢。我已经阅读了WROX书,这个例子实际上并没有显示.master页面在其他内容页面中如何链接?有点关键点没有?

我错过了什么吗?

Rob。

P.S。那天我发现一本实际上有用的书,而不仅仅是覆盖该主题旁边的一个复选标记。 - 当然有MSDN(这是一个什么笑话,我曾经见过的最糟糕的文档 - 样本??没有
链接或列表可以使用什么参数,什么都没有。抱歉,只是非常感到沮丧的是完全缺乏有用的文档,这些文档并不需要花费很多时间来玩搜索和搜索游戏。如果我将我的代码记录为与MSDN文档VS 2005一样糟糕,我很久以前就失业了。



没有得到它,是的我有这本书。


在我的Master.master中,我有一个HTML表格,其中包含传统的标题

(顶部),LeftSideBar(左),主要内容(中间),页脚(底部)每个
表格单元格有ContentPlaceHolder(ID,cph_Header,cph_LeftSideBar,
cph_PrimaryContent,cph_Footer)。


我创建了一个Header.aspx链接到Master,

Header.aspx中的
-

.... @ Page Language =" VB" M asterPageFile ="〜/ Master.master"

AutoEventWireup =" false"的CodeFile = QUOT; Header.aspx.vb" Inherits =" Header"

title =" Header" ...


....< asp:Content ID =" c_Header" ContentPlaceHolderID =" cph_Header"

Runat =" Server"> ...

在Footer.aspx中
-

.... @ Page Language =" VB" MasterPageFile ="〜/ Master.master"

AutoEventWireup =" false"的CodeFile = QUOT; Footer.aspx.vb" Inherits =" Footer"

title =" Footer" ...


....< asp:Content ID =" c_Footer" ContentPlaceHolderID =" cph_Footer"

Runat =" Server"> ...


in LeftSideBar.aspx

。 ... @ Page Language =" VB" MasterPageFile ="〜/ Master.master"

AutoEventWireup =" false" CodeFile =" LeftSideBar.aspx.vb"

Inherits =" LeftSideBar" title =" SideBar" ...


....< asp:Content ID =" c_LeftSideBar" ContentPlaceHolderID =" cph_LeftSideBar"

Runat =" Server"> ...


在PrimaryContent.aspx中

。 ... @ Page Language =" VB" MasterPageFile ="〜/ Master.master"

AutoEventWireup =" false" CodeFile =" PrimaryContent.aspx.vb"

Inherits =" PrimaryContent" title =" Content" ...


....< asp:Content ID =" c_PrimaryContent"

ContentPlaceHolderID =" cph_PrimaryContent" Runat =" Server"> ...


如果我正在使用浏览器进行测试,那么我会引用哪个页面?我还需要

另一页吗?这是我很困惑的地方。我不能引用Master.master

,因为这意味着什么。我期望VS 2005做的事情(如果我在创建VS的开发团队中获得
)会自动创建一个Master.aspx

(这就是我想要的)从浏览器会话中引用) - 但VS 2005

不这样做所以我在这一点上卡住了吗?


谢谢,Rob 。

" Bruno Alexandre" <峰; br ********* @ gmail.com>在消息中写道

新闻:uJ ************** @ TK2MSFTNGP04.phx.gbl ...

我忘了告诉你......在你的Master.Page中你需要至少有一个ContentPlaceHolder,

< asp:ContentPlaceHolder id =" leftPane" RUNAT = QUOT;服务器" >
< / asp:ContentPlaceHolder>

所以,服务器可以采取内容页面并将实际内容放在
$ b $中b在您的内容页面中,您需要使用上面的示例在PlaceHolder
控件内编写代码:

< asp:Content id =" myLeftContent" ContentPlaceHolder =" leftPane"
runat =" server">

...你的html / asp.net / javascript代码:-)

< ; / asp:内容>



Bruno Alexandre
(葡萄牙人在K?benhanv,丹麦)

Rob R. Ainscough < RO ***** @ pacbell.net> escreveu na mensagem
新闻:%2 **************** @ TK2MSFTNGP03.phx.gbl ...

再次出现另一个简单的概念不要直观或者我只是愚蠢。我已经阅读了WROX书,这个例子实际上并没有显示.master页面如何在其他内容页面中链接?有点关键点没有?

我错过了什么?

Rob。

P.S。那天我发现一本实际上有用的书,而不仅仅是覆盖该主题旁边的一个复选标记。 - 当然有MSDN(这是一个什么笑话,我曾经见过的最糟糕的文档 - 样本??没有
链接或列表可以使用什么参数,什么都没有。抱歉,只是非常感到沮丧的是完全缺乏有用的文档,这些文档并不需要花费很多时间来玩搜索和搜索游戏。如果我记录的代码与MSDN文档VS 2005一样糟糕,我很长一段时间都会失业。




Again another simple concept that appears NOT to be intuitive or I''m just
stupid. I''ve read the WROX book and the example doesn''t actually show how
the .master page links in the other content pages? Kinda sorta a critical
point no?

Am I missing something?

Rob.

P.S. the day I find a book that actually is useful rather than just a
checkmark next to "covered that topic" -- of course there is MSDN (what a
joke that is, worst documentation I''ve ever wittnessed -- samples?? no
links or lists of what parameters can be used, nothing. Sorry, just very
frustrated with complete lack of useful documentation that doesn''t require
many hours playing the search and hunt game. If I documented my code as
poorly as MSDN documents VS 2005, I would be out of a job a long time ago.

解决方案

Professional ASP.NET 2.0 from Wrox is my Bible :-D since ASP 3.0 I just love
their books ...

....but, back to your problem...

hopping that you have the same book, look at page 252 and you will see that
they have 2 files

MyMaster.master (the master page) and
Default.aspx (the default page)

in Listing 8.1: A sample Master Page (p.254)
you can see that ALL MASTER PAGES start with:

<%@ Master ...

and in the Listing 8.3: The content page that uses Wrox.Master (p.258)
you can see that ALL CONTENT PAGES have in the start line
<%@ ... MasterPageFile="Wrox.master" ...
even if you do not have the book, I think I made my point ;-)

--

Bruno Alexandre
(a Portuguese in K?benhanv, Danmark)
"Rob R. Ainscough" <ro*****@pacbell.net> escreveu na mensagem
news:%2****************@TK2MSFTNGP03.phx.gbl...

Again another simple concept that appears NOT to be intuitive or I''m just
stupid. I''ve read the WROX book and the example doesn''t actually show how
the .master page links in the other content pages? Kinda sorta a critical
point no?

Am I missing something?

Rob.

P.S. the day I find a book that actually is useful rather than just a
checkmark next to "covered that topic" -- of course there is MSDN (what a
joke that is, worst documentation I''ve ever wittnessed -- samples?? no
links or lists of what parameters can be used, nothing. Sorry, just very
frustrated with complete lack of useful documentation that doesn''t require
many hours playing the search and hunt game. If I documented my code as
poorly as MSDN documents VS 2005, I would be out of a job a long time ago.



I forgot to tell you...

in your Master.Page you need to have a minimum of ONE ContentPlaceHolder,
like

<asp:ContentPlaceHolder id="leftPane" runat="server" >
</asp:ContentPlaceHolder>

so, the Server could take the conten page and put the actual content in the
place holder
in your content pages you need to write the code inside a PlaceHolder
control, using the example above:

<asp:Content id="myLeftContent" ContentPlaceHolder="leftPane"
runat="server">

... your html / asp.net / javascript code :-)

</asp:Content>


--

Bruno Alexandre
(a Portuguese in K?benhanv, Danmark)
"Rob R. Ainscough" <ro*****@pacbell.net> escreveu na mensagem
news:%2****************@TK2MSFTNGP03.phx.gbl...

Again another simple concept that appears NOT to be intuitive or I''m just
stupid. I''ve read the WROX book and the example doesn''t actually show how
the .master page links in the other content pages? Kinda sorta a critical
point no?

Am I missing something?

Rob.

P.S. the day I find a book that actually is useful rather than just a
checkmark next to "covered that topic" -- of course there is MSDN (what a
joke that is, worst documentation I''ve ever wittnessed -- samples?? no
links or lists of what parameters can be used, nothing. Sorry, just very
frustrated with complete lack of useful documentation that doesn''t require
many hours playing the search and hunt game. If I documented my code as
poorly as MSDN documents VS 2005, I would be out of a job a long time ago.



Nope not getting it, yes I have the book.

In my Master.master I have an HTML table laided out with tranditional Header
(top), LeftSideBar (left), Primary Content (middle), Footer (bottom) in each
table cell has ContentPlaceHolder (IDs, cph_Header, cph_LeftSideBar,
cph_PrimaryContent, cph_Footer).

I''ve created a Header.aspx that links to the Master,

in Header.aspx --
....@ Page Language="VB" MasterPageFile="~/Master.master"
AutoEventWireup="false" CodeFile="Header.aspx.vb" Inherits="Header"
title="Header"...

....<asp:Content ID="c_Header" ContentPlaceHolderID="cph_Header"
Runat="Server">...

in Footer.aspx --
....@ Page Language="VB" MasterPageFile="~/Master.master"
AutoEventWireup="false" CodeFile="Footer.aspx.vb" Inherits="Footer"
title="Footer"...

....<asp:Content ID="c_Footer" ContentPlaceHolderID="cph_Footer"
Runat="Server">...

in LeftSideBar.aspx
....@ Page Language="VB" MasterPageFile="~/Master.master"
AutoEventWireup="false" CodeFile="LeftSideBar.aspx.vb"
Inherits="LeftSideBar" title="SideBar"...

....<asp:Content ID="c_LeftSideBar" ContentPlaceHolderID="cph_LeftSideBar"
Runat="Server">...

in PrimaryContent.aspx
....@ Page Language="VB" MasterPageFile="~/Master.master"
AutoEventWireup="false" CodeFile="PrimaryContent.aspx.vb"
Inherits="PrimaryContent" title="Content"...

....<asp:Content ID="c_PrimaryContent"
ContentPlaceHolderID="cph_PrimaryContent" Runat="Server">...

So what page do I reference if I''m testing from a Browser?? Do I need yet
another page?? This is where I''m confused. I can''t reference Master.master
as that means nothing. What I would have expected VS 2005 to do (if I were
on the dev team that created VS) is automatically create a Master.aspx
(which is what I would reference from a Browser session) -- but VS 2005
doesn''t do this so I''m stuck at this point?

Thanks, Rob.
"Bruno Alexandre" <br*********@gmail.com> wrote in message
news:uJ**************@TK2MSFTNGP04.phx.gbl...

I forgot to tell you...

in your Master.Page you need to have a minimum of ONE ContentPlaceHolder,
like

<asp:ContentPlaceHolder id="leftPane" runat="server" >
</asp:ContentPlaceHolder>

so, the Server could take the conten page and put the actual content in
the place holder
in your content pages you need to write the code inside a PlaceHolder
control, using the example above:

<asp:Content id="myLeftContent" ContentPlaceHolder="leftPane"
runat="server">

... your html / asp.net / javascript code :-)

</asp:Content>


--

Bruno Alexandre
(a Portuguese in K?benhanv, Danmark)
"Rob R. Ainscough" <ro*****@pacbell.net> escreveu na mensagem
news:%2****************@TK2MSFTNGP03.phx.gbl...

Again another simple concept that appears NOT to be intuitive or I''m just
stupid. I''ve read the WROX book and the example doesn''t actually show
how the .master page links in the other content pages? Kinda sorta a
critical point no?

Am I missing something?

Rob.

P.S. the day I find a book that actually is useful rather than just a
checkmark next to "covered that topic" -- of course there is MSDN (what a
joke that is, worst documentation I''ve ever wittnessed -- samples?? no
links or lists of what parameters can be used, nothing. Sorry, just very
frustrated with complete lack of useful documentation that doesn''t
require many hours playing the search and hunt game. If I documented my
code as poorly as MSDN documents VS 2005, I would be out of a job a long
time ago.




这篇关于母版页,如何使它们工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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