Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CalcState state = ViewState["state"] as CalcState;
            if (state != null)
                history = state.History;

            if (IsPostBack)
            {
                int result = int.Parse(firstValue.Value) + int.Parse(secondValue.Value);
                resultValue.InnerText = result.ToString();
                history.Insert(0, string.Format("{0} + {1} = {2}", firstValue.Value, secondValue.Value, result));
                ViewState["state"] = new CalcState
                                         {
                                             History = history
                                         };
                DataBind();
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //CalcState state = ViewState["state"] as CalcState;
            //if (state != null)
            //{
            //    history = state.History;
            //}

            if (IsPostBack)
            {
                int result = int.Parse(firstValue.Value) + int.Parse(secondValue.Value);
                resultValue.InnerText = result.ToString();
                history.Insert(0, string.Format("{0} + {1} = {2}",
                                                firstValue.Value, secondValue.Value, result));
                ViewState["state"] = new CalcState
                {
                    History = history.Count > 3 ? history.GetRange(0, 3) : history
                };
                DataBind();
            }
        }