protected void CreateMsgs(object sender, EventArgs e) { enter obj = new enter(); int success = obj.InsertMessage((int)Session["userid"], (int)Session["msgid"], t.Text); if (success == -1) { msgtxt.Text = "Connection Failure! Try Again!"; } else { var cis = ControlIds; int id = ControlIds.Count + 1; cis.Add(id); ControlIds = cis; var ts = Texts; ts.Add(t.Text); Texts = ts; var dts = Times; var now = DateTime.Now; dts.Add(now); Times = dts; Label message = new Label(); message.ID = "msg" + id; message.Text = t.Text; message.Attributes.Add("style", "font-size: 20px;"); message.Attributes.Add("runat", "server"); Label time = new Label(); time.ID = "time" + id; time.Attributes.Add("style", "text-align: right;"); time.Text = "<sub>" + now + "</sub>"; news.Controls.Add(new LiteralControl("<div style=\"border: solid; border-color: azure; background-color: rgba(18, 12, 85, 0.6); color: white; text-align: left \">")); news.Controls.Add(message); news.Controls.Add(new LiteralControl("<br/>")); news.Controls.Add(time); news.Controls.Add(new LiteralControl("</div>")); news.Controls.Add(new LiteralControl("<br/><br/>")); t.Text = ""; } }