protected void Button1_Click(object sender, EventArgs e) { Comment comment = new Comment(); comment.NameUser = Request.Form["nam"]; comment.StrComment = Request.Form["com"]; if ((comment.NameUser != "") && (comment.StrComment != "")) { RepositoryOfComments.GetRepository().AddComment(comment); } GetComments(); }
protected void GetComments() { StringBuilder html = new StringBuilder(); var Data = RepositoryOfComments.GetRepository().GetAllComments(); foreach (var com in Data) { Panel1.Controls.Add(new Label() { Text = '-' + com.NameUser, CssClass = "LabelName" }); Panel1.Controls.Add(new Panel()); Panel1.Controls.Add(new Label() { Text = com.StrComment, CssClass = "LabelStrComment" }); Panel1.Controls.Add(new Panel()); } }