页面A,页面B都调用页面C时,点击页面C的返回按钮时,返回到调用时的页面

功能描述:当点击页面A的“详细信息”时,跳转到页面C,点击页面C的“返回”按钮时返回到页面A ;当点击页面B的“查看”时,跳转到页面C,点击页面C的“返回”按钮时返回到页面B

代码:

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)//记录上一个页面地址
            {
                string strUrl = Request.UrlReferrer.AbsolutePath;
                ViewState["Url"] = strUrl;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)//返回
        {
            string strUrl = ViewState["Url"].ToString();
            Response.Redirect(strUrl);
        }

posted @ 2012-04-06 15:36  完美的爱  阅读(1482)  评论(0编辑  收藏  举报