If you need to save at the "global" level, you must use the state of the application. You can also use the Cache object. You might want to pass values ββfrom one page to another, you can achieve this using the Context object in conjunction with Server.Transfer.
1) You need a public property on the original page that returns the value to pass
namespace SomeNameSpace { public partial class SourcePage: System.Web.UI.Page { public string ValueToPass { get { if (Context.Items["ValueToPass"] == null) Context.Items["ValueToPass"] = string.Empty; return (string)Context.Items["ValueToPass"]; } set { Context.Items["ValueToPass"] = value; } } ........ } }
2) Make Server.Transfer (DestinationPage.aspx) 3) In the Page_Load event of the landing page
namespace SomeNameSpace { public partial class SourcePage: System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var value = this.Context.Items["ValueToPass"]; } } }
Hope this helps
source share