close

情境:client -請求> A.aspx -轉頁> B.aspx
問題:如何讓B頁取得上一頁(A)的值?

方法:用「VirtualPath」屬性

1. 「MasterType」,B.aspx:

<%@ MasterType VirtualPath="~/page/A.Master" %>

Note: 使用 Master page 的方法:

<%@ MasterPageFile="~/page/A.Master" %>

 

2. 「PreviousPageType」:

<%@ PreviousPageType VirtualPath="~/page/A.aspx" %>

 

更多網頁轉址與傳值方法、差異與細節:
ASP.NET網頁間轉址和傳值方式
ASP.NET傳值的3個方法 (Response.Redirect、Server.Transfer、Server.Execute)
在 ASP.NET 頁面中取得 MasterPage 的具型別物件資料
ASP.NET 使用MasterPage跨網頁傳遞參數問題
ASP.Net Master Pages: Tips, Tricks, and Traps
*[ASP.NET]Response.Redirect與Server.Transfer差別
undefined
*Difference Between Response.Redirect() and Server.Transfer() Methods in ASP.NET
 

  Context.Items.Add("Name", "Sandeep Singh Shekhawat");
  Context.Items.Add("Email", "sandeep.shekhawat88@gmail.com");
  Server.Transfer("UserDetail.aspx");
// - - -
  Response.Write(string.Format("My name is {0} and email address is {1}",
  Context.Items["Name"].ToString(),
  Context.Items["Email"].ToString()));

 

 

arrow
arrow

    Robert 發表在 痞客邦 留言(0) 人氣()