protected void btnAddMsg_Click(object sender, EventArgs e) { Message msg = new Message(); if (this.User.Identity.Name != "") { msg.username = this.User.Identity.Name; msg.timestamp = DateTime.Now; msg.comment = txtComment.Text; Application.Lock(); MessageList msgList = (MessageList)Application["ShoutBox"]; msgList.Add(msg); Application.UnLock(); lblShoutBox.Text = msgList.ToString(); Session["Feedback"] = txtComment.Text; txtComment.Text = ""; txtComment.Focus(); Response.Redirect("~/ThankYou.aspx"); } else { lblLogin.Text = "Please log in to contact the site admins. "; } }
public void Add(Message msg) { purge(); System.Threading.Thread.Sleep(2000); msgList.Add(msg);//I like my lists arranged from oldest to newest }