将母版页附加到Web表单 [英] attaching master page to web form

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

问题描述

大家好,

我在ASP> NET编写一个项目,C#我有一个名为Login.aspx的Web表单,没有任何Master Page。我可以附加一个母版页吗?对于它。

非常感谢

解决方案

通过向网站布局添加网页母版页面,您可以添加此代码。



 <%@       语言  =  C#    AutoEventWireup   =  true    CodeFile   =  Site.master.cs    继承  = 网站 < span class =code-attribute>  %>  
< !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 < span class =code-keyword>> Untitled Page < / title < span class =code-keyword>>
< asp:ContentPlaceHolder id = head runat = server >
< / asp:ContentPlaceHolder >
< / head >
< body >
< 表单 id = form1 runat = < span class =code-keyword> server >
< div >
< asp:ContentPlaceHolder id = ContentPlaceHolder1 runat = server >

< / asp:ContentPlaceHolder < span class =code-keyword>>
< / div >
< / form >
< / body >
< / html >


< blockquote>

<%页面%>标签只需添加母版页名称
MasterPageFile =〜/ MasterPage.Master
像这样..


 <%@     Page    标题  =    语言  =  C#    MasterPageFile   = 〜/ MasterPage.master    AutoEventWireup   =  true    CodeFile   =  Login.aspx.cs   < span class =code-attribute>继承  = 登录   %>  

< asp:内容 ID = Content1 ContentPlaceHolderID = head Runat = 服务器 > < / asp:内容 >

< asp:内容 ID = Content2 ContentPlaceHolderID = ContentPlaceHolder1 Runat = 服务器 > < / asp:Content >


hi all,
I am writing a project in ASP>NET,C# that I have a web form named Login.aspx that is not have any Master Page.how can I Attach a master Page for it.
thanks alot

解决方案

by adding a web master page to site layout you can add this code..

<%@ 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">
 </asp:ContentPlaceHolder>
</head>
<body>
 <form id="form1" runat="server">
 <div>
 <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

 </asp:ContentPlaceHolder>
 </div>
 </form>
</body>
</html>


In the <%page%> tag just add the master page name 
MasterPageFile="~/MasterPage.Master"
Like this..


<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"></asp:Content>


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

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