Source code location: ./passing_values/pageb.aspx.cs
using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace PassingValues { public class PageB : Page { protected Literal litTitle; protected Literal litPrice; private double Price { get { return Convert.ToInt32 (ViewState ["price"]); } set { ViewState ["price"] = value; } } private string Title { get { return Convert.ToString (ViewState ["title"]); } set { ViewState ["title"] = value; } } protected override void OnLoad(System.EventArgs e) { base.OnLoad (e); litTitle.Text = this.Title; litPrice.Text = this.Price.ToString("c"); } protected override void OnInit(EventArgs e) { base.OnInit (e); if (!(HttpContext.Current.Handler is PageA)) throw new InvalidOperationException ("We didn't get here by way of Server.Transfer"); PageA previousPage = (PageA) HttpContext.Current.Handler; this.Title = previousPage.Title; this.Price = previousPage.Price; } } }
Copyright © 2004-2006, Milan Negovan. All rights reserved. | License
Back to AspNetResources.com