将母版页附加到default.aspx [英] attaching a masterpage to default.aspx

查看:108
本文介绍了将母版页附加到default.aspx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生!

我想将一个母版页附加到default.aspx!

我怎么能

解决方案

通过添加新项目选项添加新页面时,有一个复选框,用于选择要装箱的页面的母版页。因此,您可以通过选中该选项来创建创建时的默认页面...





[ ^ ]你可以在这里查看,等等......





[ ^ ]






添加

<前lang =cs> MasterPageFile = < span class =code-string> 〜/ Master.master



to代码文件顶部的 @ Page 指令。



示例(示例取自此MSDN页面 [<小时ef =http://msdn.microsoft.com/en-us/library/wtxbf3hh%28v=vs.100%29.aspxtarget =_ blanktitle =New Window> ^ ]) :

<%@ Page Language =   C#   MasterPageFile =  〜/ Master.master 标题=  内容页面1 %>  
< asp:Content ID = Content1 ContentPlaceHolderID = Main Runat = 服务器 >
主要内容。
< / asp:内容 >

< asp:Content ID = Content2 ContentPlaceHolderID = 页脚 Runat = 服务器 >
页脚内容。
< / asp:content >



希望这会有所帮助。


创建一个新页面母版页:



添加新项目时,将打开一个对话框,提供要保存的名称,其中有一个复选框,'选择Master Page',检查并确认,然后打开另一个对话框。在那里你需要选择母版页。 &安培;现在将选择母版页。



添加包含现有页面的母版页:



 <%@     Page    语言  =   C#    MasterPageFile   =  Masterpage.master    AutoEventWireup   =  true  

CodeFile = default.aspx.cs 标题 = Untitled Page %>





此代码将在default.aspx的设计页面中提供,(页面的第一行)



你应该添加

 MasterPageFile =Masterpage.master


sir !
I want to attach a masterpage to a default.aspx!
how I can

解决方案

While adding a new page by add new item option..there is a checkbox to select the master page for the page you are crating. so you can child your default page at time of creation by checking that option...


[^] You can check here and HEre...


[^]


Hi,

Add

MasterPageFile="~/Master.master"


to the @ Page directive at the top of your code file.

Example (example taken from this MSDN page[^]):

<% @ Page Language="C#" MasterPageFile="~/Master.master" Title="Content Page 1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
    Main content.
</asp:Content>
    
<asp:Content ID="Content2" ContentPlaceHolderID="Footer" Runat="Server" >
    Footer content.
</asp:content>


Hope this helps.


To create a new Page with Master Page:

While Add a new Item, A dialog Box will open to give the name to save, there one check box will be there, 'select Master Page', Check that and give ok, and another Dialog Box will open. There you need to select Master Page. & now Master Page will be selected.

To Add the Master Page with Existing Page:

<%@ Page Language="C#" MasterPageFile="Masterpage.master" AutoEventWireup="true"

    CodeFile="default.aspx.cs" Title="Untitled Page" %>



This code will be available in the design page of default.aspx, (First Line of the Page)

you should add

MasterPageFile="Masterpage.master"


这篇关于将母版页附加到default.aspx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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