Пример #1
0
        /// <summary>
        /// Perform any updates before the output is rendered. Any  changes at this point
        ///  to the state of the control can be saved and the ones in the rendering phase are lost
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_PreRender(object sender, EventArgs e)
        {
            using (ShoppingCartEngine usersShoppingCart = new ShoppingCartEngine())
            {
                //format the cart count
                string cartStr = string.Format("Cart [{0}]", usersShoppingCart.GetCount());


                if (cartStr != null && cartCount != null)
                {
                    try
                    {
                        cartCount.InnerText = cartStr;
                    }
                    catch (Exception ex)
                    {
                        HttpContext.Current.Session["Error"] = ex;
                        HttpContext.Current.Response.Redirect("/UserPages/ErrorPage.aspx");
                    }
                }

                if (usersShoppingCart.GetCount() > 0)
                {
                    contentCartCounter.Visible = true;
                }
                else
                {
                    contentCartCounter.Visible = false;
                }
            }
        }