c# - 在所有网页上使用相同的页眉和页脚

标签 c# html css asp.net webforms

我正在使用 Visual Studio 构建 ASP.NET 网站。

我想在所有页面上重复使用页眉和页脚,而不是将 HTML 复制到所有页面。

我已经查看了以下答案,但它们都是为 PHP 编写的。有人可以帮助展示如何在 ASP.NET 中执行此操作吗?

How to display same header and footer on different pages?

Keeping my header and footer on all webpages?

最佳答案

你应该使用 ASP.NET Master Pages为此目的:

ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application. You can then create individual content pages that contain the content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.

母版页让您可以集中页面的常用功能,这样您就可以在一个地方进行更新。

关于c# - 在所有网页上使用相同的页眉和页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33330735/

相关文章:

c# - 使用 MarshalAs 和 StructLayout 读取二进制数据

c# - 如何在 UWP 中创建 Tab Header Pivot 控件?

javascript - 如果动态添加,jQuery 选择不起作用

css - 将 Bootstrap 组件排成一行

c# - 如何在字符串中的条件运算符前后添加空格?

c# - 从 LinkedList<> 中删除项目

php脚本包含不同目录中的html

javascript - HTML/Javascript - 创建自动滚动的页面部分,并在顶部文本离开屏幕时将其删除

javascript - 如何使用 jquery 仅删除 #Chat 中的选定消息?

css - React-Native 中的双模态?