使用ASP.NET 3.5 Extensions管理浏览器历史:使用客户端

ASP.NET 3.5 浏览器历史管理
本文介绍如何使用 ASP.NET 3.5 Extensions 的客户端脚本功能来管理浏览器的历史记录,通过三个按钮触发不同状态的保存,并展示如何通过 Sys.Application 对象的 navigate 事件和 addHistoryPoint 方法实现历史记录的管理和回溯。

1.新建一个web form,代码如下,注意黄色部分

image

2.浏览效果

image

3.贴一个微软提供的示例:

Microsoft sample code
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><%@ Page Language="C#" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.Collections.Generic" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    
<title>Microsoft ASP.NET 3.5 Extensions</title>
    
<link href="http://www.cnblogs.com/include/qsstyle.css" type="text/css" rel="Stylesheet" />

    
<script type="text/javascript">
        
function page_init() {
            Sys.Application.add_navigate(onStateChanged);
            
var cb1 = $get('clientButton1');
            
var cb2 = $get('clientButton2');
            
var cb3 = $get('clientButton3');
            $addHandler(cb1, 
"click", clientClick);
            cb1.dispose 
= function() { $clearHandlers(cb1); }
            $addHandler(cb2, 
"click", clientClick);
            cb2.dispose 
= function() { $clearHandlers(cb2); }
            $addHandler(cb3, 
"click", clientClick);
            cb3.dispose 
= function() { $clearHandlers(cb3); }
        }

        
        
function onStateChanged(sender, e) {
            
// When the page is navigated, this event is raised.
            var val = parseInt(e.get_state().s || '0');
            Sys.Debug.trace(
"Navigated to state " + val);
            $get(
"div2").innerHTML = val;
        }

        
        
function clientClick(e) {
            
// Set a history point in client script.
            var val = parseInt(e.target.value);
            Sys.Application.addHistoryPoint(
{s: val}"Click Button:" + val);
            Sys.Debug.trace(
"History point added: " + val);
       }

    
</script>
</head>
<body>
    
<form id="form1" runat="server">
        
<div>
            
<asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="false" EnableHistory="true" />
            
<script type="text/javascript">
                Sys.Application.add_init(page_init);
            
</script>
            
<h2>
                Microsoft ASP.NET 3.5 Extensions: Managing Browser History with Client Script
</h2>
            
</>
            
<div id="Div1" class="new">
                
<p>
                    This sample shows:
</p>
                
<ol>
                    
<li>The <code>Sys.Application</code> object and the <code>navigate</code> event and <code>addHistoryPoint</code> method.</li>
                    
<li>The <code>addHistoryPoint</code> method demonstrates addition of titles.</li>
                
</ol>
            
</div>
            
<p>
            
</p>
            
<h2>Example 1: Managing browser history in client script</h2>
            
<p>This example includes three buttons. The handler for each button's <code>click</code> event sets
            navigation history points using the 
<code>Sys.Application</code> object. The script used here, makes use of the 
            
<code>Sys.Debug</code> class to dump trace information to the TEXTAREA at the bottom of the page. 
            
</p>
            
<p>When you click the buttons, and history points are added, you will be able to see the list of history entries and their titles in the 
            "Recent Pages" drop-down in Internet Explorer, for example.
            
</P>
            
<p>To see history in action, perform the following steps:</p>

            
<ol>
                
<li>Press <b>1</b>. See the trace output.</li>
                
<li>Press <b>3</b>. See the trace output.</li>
                
<li>Press <b>2</b>. See the trace output.</li>
                
<li>Press the browser's Back button. Notice that the page is refreshed with previous data and 
                that trace information shows this.
</li>
            
</ol>
            
<div id="div2" class="box">0</div><p></p>
                
<input type="button" id="clientButton1" value="1" />
                
<input type="button" id="clientButton2" value="2" />
                
<input type="button" id="clientButton3" value="3" />
            
<br /><br />
            
<textarea id="TraceConsole" cols="40" rows="5"></textarea>
        
</div>
    
</form>
</body>
</html>
提供了一个基于51单片机的RFID门禁系统的完整资源文件,包括PCB图、原理图、论文以及源程序。该系统设计由单片机、RFID-RC522频射卡模块、LCD显示、灯控电路、蜂鸣器报警电路、存储模块和按键组成。系统支持通过密码和刷卡两种方式进行门禁控制,灯亮表示开门成功,蜂鸣器响表示开门失败。 资源内容 PCB图:包含系统的PCB设计图,方便用户进行硬件电路的制作和调试。 原理图:详细展示了系统的电路连接和模块布局,帮助用户理解系统的工作原理。 论文:提供了系统的详细设计思路、实现方法以及测试结果,适合学习和研究使用。 源程序:包含系统的全部源代码,用户可以根据需要进行修改和优化。 系统功能 刷卡开门:用户可以通过刷RFID卡进行门禁控制,系统会自动识别卡片并判断是否允许开门。 密码开门:用户可以通过输入预设密码进行门禁控制,系统会验证密码的正确性。 状态显示:系统通过LCD显示屏显示当前状态,如刷卡成功、密码错误等。 灯光提示:灯亮表示开门成功,灯灭表示开门失败或未操作。 蜂鸣器报警:当刷卡或密码输入错误时,蜂鸣器会发出报警声,提示用户操作失败。 适用人群 电子工程、自动化等相关专业的学生和研究人员。 对单片机和RFID技术感兴趣的爱好者。 需要开发类似门禁系统的工程师和开发者。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值