如何在asp.net c#中包含网页的页眉、页脚、侧边栏?

如何在asp.net c#中包含网页的页眉、页脚、侧边栏?,c#,asp.net,C#,Asp.net,我刚加入asp.net,我有点困惑如何在网页中添加页眉/页脚 我正在使用visual studio 2012 我们在PHP中使用include和require预定义函数 我不知道我们在asp.net中为网站使用了什么 请告诉我 感谢使用母版页,允许您创建页眉、页脚、侧边栏和其他内容的母版副本。所有“内容”页面都继承母版页,并在母版页内的预定义“内容区域”中呈现 创建母版页时,它应该有一个默认的“内容占位符”。围绕它构建母版页,添加新页时,选择“内容页”,或在早期的Visual Studio版本中

我刚加入asp.net,我有点困惑如何在网页中添加页眉/页脚

我正在使用visual studio 2012

我们在PHP中使用include和require预定义函数

我不知道我们在asp.net中为网站使用了什么

请告诉我


感谢使用母版页,允许您创建页眉、页脚、侧边栏和其他内容的母版副本。所有“内容”页面都继承母版页,并在母版页内的预定义“内容区域”中呈现

创建母版页时,它应该有一个默认的“内容占位符”。围绕它构建母版页,添加新页时,选择“内容页”,或在早期的Visual Studio版本中选择“使用母版页”,然后选中“使用母版页”框

然后,您将看到新的内容页,母版页在后台淡出,您可以构建内容页


调用内容页(绑定到母版页的普通页),总是将母版页和内容页作为一个页面呈现到屏幕上。

使用母版页并根据需要添加页眉div和页脚

<div style="margin-left: 38%; width: 25%;">
    Header
 </div>
    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
    </asp:ContentPlaceHolder>
    <div style="margin-left: 38%; width: 25%;">
        <hr style="color: #1B3280; border-width: thin; width: 98%;" />
    </div>
    <div>
        <asp:Label ID="Label" runat="server" CssClass="rights" Font-Size="12px" Font-Names="Calibri"
            Text="All rights reserved."></asp:Label>
    </div>

标题


对于WebForms使用
母版页
对于MVCIf使用
布局
对于asp.net您是新手,我建议您阅读一些入门教程。您是使用WebForms还是MVC?Hanno完全同意这一点。即使这个问题得到了回答,毫无疑问,OP会在每一个关卡上都被卡住,直到他们阅读了教程