使用主页面(shtml)
最编程
2024-07-08 14:39:41
...
使用母版页
1.网页很多地方长得一样,也有不一样的地方,Webform的母版页(MasterPage),使用母版页的窗体。 2.母版页太笨重。(加载母版页,然后进行多次填坑,麻烦!) 3.母版页使用ContentPlaceHolder挖坑,“使用母版页的窗体”用Content填坑
案例—1
新建一个母版页peo.Master
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="peo.master.cs" Inherits="wj.peo" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></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>
<asp:ContentPlaceHolder ID="contentplaceholder2" runat="server">
</asp:ContentPlaceHolder>
</body>
</html>
新建使用母版页的Web窗体
<%@ Page Title="" Language="C#" MasterPageFile="~/peo.Master" AutoEventWireup="true" CodeBehind="muban1`.aspx.cs" Inherits="wj.muban1_" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<!--这里在模板页的第一个位置写内容-->
<script type="text/javascript">
alert("欢迎进入本网页!");
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
姓名:<input type="text" id="name"/>
<br />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="contentplaceholder2" runat="server">
北京|如鹏|传智|博客
</asp:Content>
推荐使用shtml轻量级母版页
4.Shtml:ServerSideInclude(SSI),主流web服务器(iis、apache等)都支持。效率高,不需要经过asp.net处理,轻量级。
<!--#include file="info.htm"-->
****服务器拼接****好页面之后就直接发送到了浏览器端了。而且服务器用了缓存技术,将拼接好的页面,缓存一段时,加快了访问时间。
案例—shtml
新建一个头html head.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
关于我们|如鹏|上海|天津|河南
<br />
新建一个尾html foot.html
<br />
友情链接|荣誉|地址|北京大学|上海大学
</body>
</html>
新建一个1.shtml调用“头”,“尾”文件,在服务器中拼接
<!--#include file="head.html"-->
<br />
<br />
我是shtml的主要部分
<br />
<br />
<!--#include file="foot.html"-->
显示效果
推荐阅读
-
# Cocos 2 嵌入页面使用 webview,摄像头调用无权限问题
-
主节点错误重启后,Flink 批次作业如何恢复执行进度?-使用 Flink 的影响
-
#分享私藏项目实操#使用10行代码,创建在线个人简历页面!
-
无法安全地连接到此页面,这可能是因为该站点使用过期的或不安全的 TLS 安全设置
-
IE 11 无法安全地连接到此页面,这可能是因为该站点使用过期的或不安全的 TLS 安全设置
-
该页面的连接存在安全问题,可能是因为该站点所使用的TLS安全设置已经过时或存在风险。
-
使用HTML实现页面自动刷新和跳转
-
使用nginx代理网页,修改页面更新后,页面内容不变。停止nginx后,发现页面仍然可以访问。
-
如何在JSP页面中使用Java类:导入Java包的步骤
-
在JSP中使用Java获取页面变量及其对象属性的方法