﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SessionStrings
{
    public partial class SessionStrings : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var Messages = Session["messages"] as List<string>;
                if (Messages == null)
                {
                    Messages = new List<string>();
                    Session["messages"] = Messages;
                }
                contentHolder.Text = "";
                foreach (var message in Messages)
                {
                    contentHolder.Text += message;
                }
            }

        }

        protected void Append_Click(object sender, EventArgs e)
        {
            var Messages = Session["messages"] as List<string>;
            if (Messages == null)
            {
                Messages = new List<string>();
                Session["messages"] = Messages;
            }
            Messages.Add(inputTextBox.Text);
            contentHolder.Text += inputTextBox.Text;
            inputTextBox.Text = "";
        }
    }
}