protected bool SaveThis() { bool ret = false; if (this.PubID > 0) { if (Page.IsValid && this.txtComment.Text.Trim().Length > 0) { PubEntAdmin.BLL.Comment l_comment = new PubEntAdmin.BLL.Comment( this.PubID, this.txtComment.Text.Trim().Replace(System.Environment.NewLine, "__CRLF__"), ((CustomPrincipal)HttpContext.Current.User).UserID, ((CustomPrincipal)HttpContext.Current.User).FullName); ret = l_comment.Save(); txtComment.Text = String.Empty; } this.BindComments(); this.lblErrmsg.Text = String.Empty; } else { this.txtComment.Text = String.Empty; this.lblErrmsg.Text = "This publication has not been created. Please add any comment after creating this publication."; } return(ret); }
protected void grdComments_ItemDataBound(Object s, DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { PubEntAdmin.BLL.Comment currentComment = (PubEntAdmin.BLL.Comment)e.Item.DataItem; Label lblCreatorDisplayName = (Label)e.Item.FindControl("lblCreatorDisplayName"); lblCreatorDisplayName.Text = currentComment.CreatorUsername; Label lblDateCreated = (Label)e.Item.FindControl("lblDateCreated"); lblDateCreated.Text = currentComment.DateCreated.ToString("f"); Literal ltlComment = (Literal)e.Item.FindControl("ltlComment"); ltlComment.Text = currentComment.CommentContent; ltlComment.Text = Page.Server.HtmlEncode(ltlComment.Text.Trim().Replace("__CRLF__", "<br>")); //ltlComment.Text = Page.Server.HtmlEncode(ltlComment.Text.Trim()); //ltlComment.Text = ltlComment.Text.Replace("__CRLF__", "<br>"); } }