页面加入_JS,CSS使用,#include添加文件,缓存页面,页面间传递汉字,IsPostBack控制页面的加载,自定义错语页面
1 页面加入_JS,
2 CSS使用,
3 #include添加文件,
4 缓存页面,
5 页面间传递汉字,
6 IsPostBack控制页面的加载,
7 自定义错语页面
=================
1 页面加入_JS,
A:直接在页面里字JAVASCRIPT,调用:
<script language="javascript">
function setfocus()
{
document.all.UserName.focus();
}
</script>
<body onload="setfocus()">
B:在页面里引用JS文件:
<script type="text/javescript" src="heade.js"></script>
<body onload="setfocus()">
2 CSS使用,
style.css:
body
{
}
.inputstype
{
font:12pt 宋体;
color:ret;
}
<link rel="stylesheet" type="text/css" href="style.css">
<ASP:TextBox id="txtUser" CssClass="inputstyle" runat="server" />
3 #include添加文件,
<body>
<!--#Include File="a.asp"-->
</body>
4 缓存页面,
.ascx;.aspx缓存在页面HTML前面加入:
<%@ OutPutCache duration="20" VaryByParam="none"%>
5 页面间传递汉字,
页面间传递参数时有汉字和其它特殊字符($#@!%^&*)时,可以进行URL编码,解码;
编码: string str2 = System.web.HttpContext.Current.Server.UrlEncode(str1);
解码: string str=System.web.HttpContent.Current.server.urlDecode(str2);
6 IsPostBack控制页面的加载,
IsPostBack是PAGE页面的一个属性,返回一个BOOL,true,false,据此值指示是否响应 客户端回发而重新加载;
private void Page_Load(Object sender,System.EventArgs e)
{
if(!IspostBack=True)
{
lab1.Text="页面每一次加载!";
}
else
{
lab1.Text="页面第二次,或3次以上加载";
}
}
7 自定义错语页面
webconfig.xml
<system.web>
<customErrors defaultRedirect="err1.aspx"
mode="On"> //出错时始终显示自己定义信息
</system.web>
2 CSS使用,
3 #include添加文件,
4 缓存页面,
5 页面间传递汉字,
6 IsPostBack控制页面的加载,
7 自定义错语页面
=================
1 页面加入_JS,
A:直接在页面里字JAVASCRIPT,调用:
<script language="javascript">
function setfocus()
{
document.all.UserName.focus();
}
</script>
<body onload="setfocus()">
B:在页面里引用JS文件:
<script type="text/javescript" src="heade.js"></script>
<body onload="setfocus()">
2 CSS使用,
style.css:
body
{
}
.inputstype
{
font:12pt 宋体;
color:ret;
}
<link rel="stylesheet" type="text/css" href="style.css">
<ASP:TextBox id="txtUser" CssClass="inputstyle" runat="server" />
3 #include添加文件,
<body>
<!--#Include File="a.asp"-->
</body>
4 缓存页面,
.ascx;.aspx缓存在页面HTML前面加入:
<%@ OutPutCache duration="20" VaryByParam="none"%>
5 页面间传递汉字,
页面间传递参数时有汉字和其它特殊字符($#@!%^&*)时,可以进行URL编码,解码;
编码: string str2 = System.web.HttpContext.Current.Server.UrlEncode(str1);
解码: string str=System.web.HttpContent.Current.server.urlDecode(str2);
6 IsPostBack控制页面的加载,
IsPostBack是PAGE页面的一个属性,返回一个BOOL,true,false,据此值指示是否响应 客户端回发而重新加载;
private void Page_Load(Object sender,System.EventArgs e)
{
if(!IspostBack=True)
{
lab1.Text="页面每一次加载!";
}
else
{
lab1.Text="页面第二次,或3次以上加载";
}
}
7 自定义错语页面
webconfig.xml
<system.web>
<customErrors defaultRedirect="err1.aspx"
mode="On"> //出错时始终显示自己定义信息
</system.web>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!