//页面缓存技术
页面部分缓存是指输出缓存页面的某些部分,而不是缓存整个页面内容。实现页面部分缓存有两种机制:一种是将页面中需
要缓存的部分置于用户控件(.ascx文件)中,并且为用户控件设置缓存功能(包含用户控件的ASP.NET页面可设置也可不设
置缓存)。这就是通常所说的“控件缓存”。设置控件缓存的实质是对用户控件进行缓存配置。主要包括以下3种方法:一
是使用@ OutputCache指令以声明方式为用户控件设置缓存功能,二是在代码隐藏文件中使用PartialCachingAttribute类设
置用户控件缓存;三是使用ControlCachePolicy类以编程方式指定用户控件缓存设置。另外,还有一种称为“缓存后替换”
的方法。该方法与控件缓存正好相反,将页面中的某一部分设置为不缓存,因此,尽管缓存了整个页面,但是当再次请求该
页时,将重新处理那些没有设置为缓存的内容。
使用@ OutputCache指令
控件缓存与页面输出缓存的@ OutputCache指令既有相似之处,又有不同的方面。二者的共同点在于它们的设置方法基本
相同,都是文件顶部设置包含属性的@ OutputCache指令字符串。不同点包括以下两个方面:一是控件缓存的@ OutputCache指
令设置在用户控件文件中,而页面输出缓存的@ OutputCache设置在普通ASP.NET文件中。二是控件缓存的@ OutputCache指令
只能设置6个属性,Duration、Shared、SqlDependency、VaryByControl、VaryByCustom和VaryByParam。而在页面输出缓存
的@ OutputCache指令字符串中设置的属性多达10个。以上是设置控件缓存时需要注意的问题。下面列举了一些利用@ OutputCache指
令设置控件缓存的示例,其中重点说明了VaryByParam和VaryByControl等属性应用。
用户控件中的@ OutputCache指令设置源代码
<%@ OutputCache Duration="120" VaryByParam="CategoryID;SelectedID"%>
以上代码设置用户控件缓存有效期时间是120秒,并且允许使用CategoryID和SelectedID参数来改变缓存。通过VaryByParam属性
设置,在服务器缓存中可能存储多个用户控件的实例。例如,对于一个包含用户控件的页面,可能存在如下的URL链接。
包含用户控件的页面的URL链接
http://localhost/mypage.aspx?categoryid=fooselectedid=0
http://localhost/mypage.aspx?categoryid=fooselectedid=1
当请求如上URL地址的页面时,由于控件中@ OutputCache指令的设置,尤其是属性VaryByParam的设置,那么在服务器缓存中就会存储两个版本的用户控件缓存实例。
控件缓存设置除了支持以上所述VaryByParam属性外,还支持VaryByControl属性。VaryByParam属性基于使用POST或者GET方式发送的名称/值对来改变缓存,而VaryByControl属性通过用户控件文件中包含的服务器控件来改变缓存。下面是VaryByControl属性的应用示例代码。
用户控件中的@ OutputCache指令设置源代码
<%@ OutputCache Duration="120" VaryByParam="none" VaryByControl="Category" %>
以上代码设置缓存有效期是120秒,并且页面不随任何GET或POST参数改变(即使不使用VaryByParam属性,但是仍然需要在@ OutputControl指令中显式声明该属性)。如果用户控件中包含ID属性为“Category”的服务器控件(例如下拉框控件),那么缓存将根据该控件的变化来存储用户控件数据。
//使用回车键在多个TextBox控件间跳转
<script>
function keyDown()
{
var MyKeycode=event.keyCode;
if (MyKeycode==13)
event.keyCode=9;
}
document.onkeydown=keyDown;
</script>
<script>
function Over(MySpan,TheID,Sum)
{
var i;
for (i=1;i<=Sum;i++)
document.getElementById(MySpan+i.toString()).style.display="none";
document.getElementById(MySpan+TheID.toString()).style.display="";
}
</script>
//播放声音文件
<bgsound src="../images/『北京欢迎你』.mp3" loop="false" balance="0" volume="0">
//返回
<a href='javascript:history.back()'>返回</a>
或者<a href='javascript:history.go(-1)'>返回</a>
//跳到顶部
<A href="javascript:window.scroll(0,0)">跳到顶部</a>
//加入收藏
onClick="window.external.AddFavorite(parent.location.href, document.title);"
//下面是一段自己写的input内控件的内容随鼠标事件改变内容的脚本
<script>
function InputMsg(ControlID,txtContent)
{
var MyControl=document.getElementById(ControlID);
if (MyControl.value==txtContent)
MyControl.value="";
}
function OutputMsg(ControlID,txtContent)
{
var MyControl=document.getElementById(ControlID);
if (MyControl.value=="")
MyControl.value=txtContent;
}
</script>
//返回当前程序所在目录,并打开当前所目录的资源管理器
Process.Start(Directory.GetCurrentDirectory());
//as 在ASP.net中的用法示例
DropDownList ddb=e.Item.FindControl("DDL_PID") as DropDownList;
同DropDownList ddb=(DropDownList)e.Item.FindControl("DDL_PID");
//下面是3秒种后自动跳转代码
<meta http-equiv="refresh" content="3; url=Index.aspx">
//自动刷新页面[该代码根据自定义的时间不停的刷新页面][本例为20秒]
====1、将以下代码加入HEML的<body></body>之间:
<meta http-equiv="refresh" content="20;url=当前页面路径">
//好酷的样式
<div id="wulang" align=center style="FONT-SIZE: 38pt; FILTER:progid:DXImageTransform.Microsoft.shadow(direction=90;color=#00CC00,strength=30); WIDTH: 100%; COLOR: #00cc00; FONT-FAMILY: 华文行楷; POSITION: absolute; HEIGHT: 56px">
恭喜恭喜,你已成为本站会员!
</div>
//左键弹出式菜单
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
<style type="text/css">
body{font: 9pt "宋体"; margintop: 0px ; color: #ffffff; background: #000000}
a.{ font: 9pt "宋体"; cursor: hand; font-size: 9pt ; color: #ffffff; text-decoration: none }
a:active{ font: 9pt "宋体"; cursor: hand; color: #FF0033 }
a.cc:hover{ font: 9pt "宋体"; cursor: hand; color: #FF0033}
.box{ font: 9pt "宋体"; position: absolute; background: #000000 }
</style></head>
<body>
<table id="itemopen" class="box" style="display:none">
<tr>
<td>弹出菜单</td>
</tr>
<tr>
<td><a href="../../../index.html" class="cc">本站首页</a></td>
</tr>
<tr>
<td><a href="../../navigation/newscript.htm" class="cc">最新更新</a></td>
</tr>
<tr>
<td><a href="../../navigation/applet/appletindex.htm" class="cc">梦想软件</a></td>
</tr>
<tr>
<td><a href="../../../jsschool/index.htm" class="cc">桌面壁纸</a></td>
</tr>
<tr>
<td><a href="popmenu.htm" class="cc">更多连接</a></td>
</tr>
<tr>
<td><a href="popmenu.htm" class="cc">更多连接</a></td>
</tr>
<tr>
<td><a href="popmenu.htm" class="cc">更多连接</a></td>
</tr>
</table>
<!-- End of Popup Menu -->
<script language="JavaScript">
document.onclick = popUp
function popUp() {
newX = window.event.x + document.body.scrollLeft
newY = window.event.y + document.body.scrollTop
menu = document.all.itemopen
if ( menu.style.display == ""){
menu.style.display = "none" }
else {
menu.style.display = ""}
menu.style.pixelLeft = newX - 50
menu.style.pixelTop = newY - 50
}
</script>
</body>
</html>
51aspx.com
//回车键的ASCII是13
//空格键的ASCII是32
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
所用语言有:Div+Css , Sql 2000 , C# , ASP.net 1.使用是类库,这样一来使得本系统相对来说安全一点; 2.用户注册使用了非中文用户名注册的验证,这样就避免了编码错误等让用户感到无助的后果; 3.弹出对话框使用了Page类下的RegisterStartupScript方法,从而避免了弹出对话框时,当用户未点击“确认”带按钮时背景隐藏的不友好的白色画面。 4.避免URL链接式注入等,当注入特定字符时捕捉信息后跳转到HackSql.aspx页面,在3秒时之后会跳转到首页。 5.用户登录使用特定的封装,从而避免了漏洞注入,单引号报错,等一些特定的注入。并且登录输入信息控件有友好的图片标签提示。 6.用户投票,弹出友好的投票信息。(用javascript脚本实现) 使用说明: 1.本系统在开发过程中得到了CSDN网友以及QQ中ASP.NET技术群网友的支持,在此表示感谢! 2.前台会员测试帐号:用户名:wulang,密码:1122; 后台普通管理员:用户名:LangRen密码:1122 后台超级管理员:用户名:admin密码:admin,登录地址:Administrators/Login.aspx 3.数据库文件是DB文件夹中的LangRen.mdf,附加即可
资源推荐
资源详情
资源评论
收起资源包目录
网站源码 Div+Css Sql 2000 C# ASP.net (543个子文件)
Global.asax 74B
Head.ascx 2KB
Bottom.ascx 2KB
UsersReg.aspx 16KB
Default.aspx 16KB
ClassResource.aspx 11KB
BBSindex.aspx 8KB
UserMsg.aspx 8KB
NewsIndex.aspx 7KB
ClassProduct.aspx 7KB
ClassNews.aspx 7KB
ClassCard.aspx 6KB
Update_News.aspx 6KB
ResourceMsg.aspx 6KB
LookAndBackCard.aspx 6KB
Learning.aspx 5KB
ApplyLink.aspx 5KB
OrderProduct.aspx 5KB
Add_Admins.aspx 5KB
Add_News.aspx 5KB
UserUploadResource.aspx 4KB
OrderMsg.aspx 4KB
MyTest.aspx 4KB
UpdateCard.aspx 4KB
UserLogin.aspx 4KB
WebMsg.aspx 4KB
Company.aspx 3KB
NewsMsg.aspx 3KB
NewsList.aspx 3KB
ProductMsg.aspx 3KB
Update_GuangGao.aspx 3KB
Add_GuangGao.aspx 3KB
Update_Resource.aspx 3KB
FindJop.aspx 3KB
UsersMsg.aspx 3KB
Update_MyFriend.aspx 3KB
Add_MyFriend.aspx 3KB
UpdateAdminMsg.aspx 3KB
PopedomAdmin.aspx 3KB
UsersList.aspx 3KB
SendCard.aspx 3KB
Add_Products.aspx 3KB
Update_Products.aspx 3KB
Show_Destine.aspx 3KB
Update_FindJop.aspx 3KB
ExecSql.aspx 2KB
ProductType.aspx 2KB
CardType.aspx 2KB
ResourceType.aspx 2KB
NewsType.aspx 2KB
Login.aspx 2KB
Add_FindJop.aspx 2KB
EditMsg.aspx 2KB
Admin_Destine.aspx 2KB
ResourceDownLoad.aspx 2KB
Top.aspx 2KB
GuangGaoList.aspx 2KB
Left.aspx 2KB
BackupData.aspx 1KB
ProductsList.aspx 1KB
MyFriendList.aspx 1KB
NewDynamic.aspx 1KB
HackSql.aspx 1KB
ReturnFileName.aspx 1KB
NoPopedom.aspx 983B
LookVote.aspx 775B
LangRen.aspx 669B
GetCode.aspx 636B
MyTextBox.aspx 614B
Web.config 6KB
Add_Admins.aspx.cs 10KB
UserMsg.aspx.cs 10KB
UsersReg.aspx.cs 9KB
ClassResource.aspx.cs 9KB
Default.aspx.cs 9KB
LookAndBackCard.aspx.cs 8KB
ReturnScript.cs 7KB
Update_Products.aspx.cs 6KB
ClassCard.aspx.cs 6KB
ClassNews.aspx.cs 6KB
Add_Products.aspx.cs 6KB
Update_News.aspx.cs 5KB
BBSindex.aspx.cs 5KB
UsersMsg.aspx.cs 5KB
UpdateCard.aspx.cs 5KB
UsersList.aspx.cs 5KB
UserUploadResource.aspx.cs 5KB
Update_GuangGao.aspx.cs 5KB
NewsList.aspx.cs 5KB
ProductType.aspx.cs 5KB
ResourceType.aspx.cs 5KB
OrderMsg.aspx.cs 5KB
CardType.aspx.cs 5KB
NewsType.aspx.cs 5KB
NewsIndex.aspx.cs 5KB
Update_MyFriend.aspx.cs 5KB
Update_Resource.aspx.cs 4KB
UpdateAdminMsg.aspx.cs 4KB
Left.aspx.cs 4KB
WebMsg.aspx.cs 4KB
共 543 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
- weixiao126com2012-11-21支持所有提供共享的同学。 代码已测试。
- wangzhongzhen0072013-09-10很好,用这个交了份作业。
- Jameswang1232013-06-20不错的代码。。。。
stormeryang
- 粉丝: 7
- 资源: 28
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功