-
HTML code
-
<% @ Page Language = " C# " AutoEventWireup = " true " CodeFile = " Default2.aspx.cs " Inherits = " Default2 " %> <! 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 runat ="server" > < title ></ title > < script src ="jquery-1.6.min.js" language ="javascript" type ="text/javascript" ></ script > < script language ="javascript" type ="text/javascript" > function GetUrl() { alert(document.getElementByIdx_x_x( ' hidden1 ' ).value); } </ script > </ head > < body > < form id ="form1" runat ="server" > < div > < input id ="Button1" type ="button" value ="获取上一页地址" onclick ="GetUrl();" /> < input id ="hidden1" type ="hidden" value ="" runat ="server" /> <% -- 隐藏域存储上一页地址 -- %> </ div > </ form > </ body > </ html >
-
C# code
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public
partial
class
Default2 : System.Web.UI.Page {
protected
void
Page_Load(
object
sender, EventArgs e) {
if
(
!
Page.IsPostBack) { hidden1.Value
=
Request.UrlReferrer.ToString(); } } }
本文介绍了一个简单的ASP.NET Web页面实例,该页面利用jQuery JavaScript库来读取服务器端设置的一个隐藏字段(hidden field)的值。通过客户端按钮点击事件触发,能够显示上一页地址的值,该值在服务器端被写入到隐藏字段中。
1601

被折叠的 条评论
为什么被折叠?



