/// <summary> /// Display the comments on page load. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { // GetSettings getSettings=new GetSettings(); var settingsValue = getSettings.GetSetting(); siteKey = settingsValue.SiteKey; if (!siteKey.IsNullOrEmpty()) { hfSitekey.Value = siteKey; //recaptchaPanel.Attributes.Add("data-sitekey", siteKey); } GetCommonSettings objCommonSettings = new GetCommonSettings(); var setting = objCommonSettings.GetCommonSetting(); _resultOnPageLoad = setting.CommentOnPageLoad; _resultPerClick = setting.CommentOnLoadMore; hfGUID.Value = Sitecore.Context.Item.ID.ToString(); hfResultsPerClick.Value = _resultPerClick.ToString(); hftotalRecords.Value = _objRepository.Retrieve(_currentItem.ToString(), true, null, null, "Ascending", "00000000-0000-0000-0000-000000000000").Count().ToString(); hfresultOnPageLoad.Value = _resultOnPageLoad.ToString(); if (_currentItem.ToString() != "") { var comments = _objRepository.Retrieve(_currentItem.ToString(), true, null, null, "Ascending", "00000000-0000-0000-0000-000000000000"); if (comments.Any()) { rptComments.DataSource = comments.Take(_resultOnPageLoad); rptComments.DataBind(); } } }
/// <summary> /// Data bind of repeator. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void rptComments_OnItemDataBound(object sender, RepeaterItemEventArgs e) { GetCommonSettings objCommonSettings = new GetCommonSettings(); var setting = objCommonSettings.GetCommonSetting(); if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { int index = 2; var itm = (Comment)e.Item.DataItem; if (itm == null) { return; } Literal ltAuthor = (Literal)e.Item.FindControl("ltAuthor"); Literal ltComment = (Literal)e.Item.FindControl("ltComment"); Literal ltDate = (Literal)e.Item.FindControl("ltDate"); var parentLi = (HtmlGenericControl)e.Item.FindControl("parentLi"); HyperLink replyCommentId = (HyperLink)e.Item.FindControl("replyCommentId"); if (ltAuthor != null) { ltAuthor.Text = itm.Author; } if (ltAuthor != null) { ltComment.Text = itm.Body; } if (ltAuthor != null) { ltDate.Text = itm.Date.ToString("f"); } if (itm.CommentId != "" && setting.Enable.ToLower() == "true") { if (replyCommentId != null) { replyCommentId.Visible = true; replyCommentId.Attributes.Add("parentcomment-id", itm.CommentId); } var child = _objRepository.Retrieve(_currentItem.ToString(), true, null, null, "Ascending", itm.CommentId) .ToList(); if (child.Any()) { var listItem = RenderCommentListing(child, index, setting.Level); if (listItem != null) { Repeater rptSecondLevel = listItem; parentLi.Controls.Add(rptSecondLevel); } } } } }
/// <summary> /// Display the comments on page load. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { GetCommonSettings objCommonSettings = new GetCommonSettings(); var setting = objCommonSettings.GetCommonSetting(); _resultOnPageLoad = setting.CommentOnPageLoad; _resultPerClick = setting.CommentOnLoadMore; hfGUID.Value = Sitecore.Context.Item.ID.ToString(); hfResultsPerClick.Value = _resultPerClick.ToString(); hftotalRecords.Value = _objRepository.Retrieve(_currentItem.ToString(), true, null, null, "Ascending").Count().ToString(); hfresultOnPageLoad.Value = _resultOnPageLoad.ToString(); if (_currentItem.ToString() != "") { var comments = _objRepository.Retrieve(_currentItem.ToString(), true, null, null, "Ascending"); if (comments.Any()) { rptComments.DataSource = comments.Take(_resultOnPageLoad); rptComments.DataBind(); } } }
/// <summary> /// Load all the comments in sitecore comment editor. /// </summary> private void LoadComments() { GetCommonSettings newGetCommonSettings = new GetCommonSettings(); Database context = Sitecore.Context.ContentDatabase; var commonSetting = newGetCommonSettings.GetCommonSetting(context); if (Pub.Any()) { lblcommentstatus.Visible = false; GridComments.PageSize = commonSetting.PageSize; GridComments.DataSource = Pub; GridComments.DataBind(); btnPublish.Visible = true; btnDelete.Visible = true; CheckApproveComment(); } else { lblcommentstatus.Visible = true; lblcommentstatus.Text = "No comments found"; } }