asp:ContentPlaceHolder的用法 [英] usage of asp:ContentPlaceHolder

查看:1299
本文介绍了asp:ContentPlaceHolder的用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vs2010中创建的新Web应用程序中工作.

我注意到母版页和网络表单页中有一个标签.请解释一下此标签的确切用法.

在母版中:

Working in a new web application created in vs2010.

I have noticed a tag in the master page and webform page.Pls explain what is the exact usage of this.

In masterpage:

<head>
<asp:ContentPlaceHolder id="head" runat="server">

</head>



在网络表格中:



In webform:

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

推荐答案

母版页旨在与内容(Webforms)页面一起使用.

因此,当您创建母版页时,您将必须修复将合并子页(内容页)的位置.因此,您将在主页面中放置一些ContentPlaceHolder,可以将其放置在页面的head body部分中.

每个html页面只能有一个html,head,body,etc.标记,因此,如果您使用的是母版页,则应将此tgs放在母版页中,这样子页一旦获得就不能再具有任何这种年龄.您只能放置
Master pages are meaned to use with Content (Webforms) pages.

So, when you create a master page, You will have to fix a place where the child page (content page) will be incorporated. hence you will put some ContentPlaceHolder inside your master page, you can put them in either head or body part of the page.

every html page can have only single html,head,body,etc. tags, so if you are using master page you will put this tgs in master page so child page can not have any of this tage once gain. you can put only
<asp:content />

标签.

在创建Webform(内容页面)并向其添加母版页时.您必须指定此表单将在母版页中驻留的位置.因此您必须选择一个ContentPlaceHolder id.


如果对解决方案感到满意,则将其标记为答案,它会激发:)

tags.

when you are creating a Webform (content page), and assinging a master page to it. you have to specify where this form will reside in master page. so you have to select a ContentPlaceHolder id.


mark as answer if satisfied with the solution, it motivates :)


ContentPlaceHolder控件为母版页中的内容定义相对区域,并从在内容页面中找到相关的内容控件.

Content控件使用其ContentPlaceHolderID属性与ContentPlaceHolder关联.在母版页中,将ContentPlaceHolderID属性设置为相关ContentPlaceHolder控件的ID属性的值.可以在一个母版页中声明多个ContentPlaceHolder.

在内容页面中,只有一个Content控件可以为母版页中的ContentPlaceHolder提供内容.但是,在使用母版页的每个内容页中,您可以具有与ContentPlaceHolder关联的单独的Content控件.例如,您可以在母版页中为页面标题定义ContentPlaceHolder.对于使用母版页的每个内容页,可以添加一个Content控件,以提供页面标题的文本和标记.
A ContentPlaceHolder control defines a relative region for content in a master page, and renders all text, markup, and server controls from a related Content control found in a content page.

A Content control is associated with a ContentPlaceHolder using its ContentPlaceHolderID property. Set the ContentPlaceHolderID property to the value of the ID property of the related ContentPlaceHolder control in a master page. More than one ContentPlaceHolder can be declared in a master page.

Within a content page, only one Content control can supply the content for a ContentPlaceHolder in the master page. However, in each content page that uses a master page, you can have separate Content controls associated with the ContentPlaceHolder. For example, you can define the ContentPlaceHolder for the page title in a master page. For each content page that uses the master page, you can add a Content control that supplies the text and markup for the page title.


这篇关于asp:ContentPlaceHolder的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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