-
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(); } } }