using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Text; public partial class ThankYou : WebBlockPage { public string OrderID { get { if (Session["SuccessfulOrderID"] != null) return Session["SuccessfulOrderID"].ToString(); else return ""; } } public string OrderAmount { get { if (Session["SuccessfulOrderAmount"] != null) return ((decimal)Session["SuccessfulOrderAmount"]).ToString("f"); else return ""; } } public ShoppingCart SuccessfulOrderCart { get { return (ShoppingCart)Session["SuccessfulOrderCart"]; } } protected void Page_Load(object sender, EventArgs e) { if (Session["SuccessfulOrderCart"] != null) { rptItems.DataSource = Session["SuccessfulOrderCart"]; rptItems.DataBind(); } if (Session["SuccessfulOrderID"] == null || Session["SuccessfulOrderAmount"] == null) Response.Redirect("Cart.aspx", true); } protected void rptShoppingCart_ItemDataBound(object sender, RepeaterItemEventArgs e) { ShoppingCartItem sci = (ShoppingCartItem)e.Item.DataItem; StringBuilder str = new StringBuilder(); str.Append("pageTracker._addItem("); if (OrderID != string.Empty) // Order ID str.Append("\"" + OrderID + "\""); if (sci.SKU != string.Empty) // SKU str.Append(",\"" + sci.SKU.Replace("\"", "\\\"").Replace("'", "\\'") + "\""); else str.Append(",\"NOSKU"); if (sci.Name != string.Empty) // Product Name str.Append(",\"" + sci.Name.Replace("\"", "\\\"").Replace("'", "\\'") + "\""); str.Append(",\"NoCategory\""); // Category str.Append(",\"" + sci.Price.ToString("f") + "\","); str.Append("\"" + sci.Quantity.ToString() + "\""); str.Append(");"); Literal litScript = (Literal)e.Item.FindControl("litScript"); litScript.Text = str.ToString(); // pageTracker._addItem( // "<%= OrderID %>", // Order ID // "NOSKU", // SKU // "Complete Order", // Product Name // "NoCategory", // Category // "<%= OrderAmount %>", // Price // "1" // Quantity //); } protected override void OnUnload(EventArgs e) { // last thing to do is clear the order info Session.Remove("OrderInfo"); base.OnUnload(e); } }