protected void btnAddShout_Click(object sender, EventArgs e) { ShoutItem shout = new ShoutItem(); shout.UserName = txtUserName.Text; shout.Comment = txtShout.Text; shout.Timestamp = DateTime.Now; Application.Lock(); ShoutItemList shoutBox = (ShoutItemList)Application["ShoutBox"]; shoutBox.Add(shout); Application.UnLock(); lblShoutBox.Text = shoutBox.Display(); txtShout.Text = ""; txtShout.Focus(); }
protected void Page_Load(object sender, EventArgs e) { ShoutItemList shoutBox; if (Application["ShoutBox"] == null) { shoutBox = new ShoutItemList(); Application.Add("ShoutBox", shoutBox); } else { shoutBox = (ShoutItemList)Application["ShoutBox"]; lblShoutBox.Text = shoutBox.Display(); } if (ScriptManager1.IsInAsyncPostBack != true) { txtUserName.Focus(); } }