Hi
I use the following code to add the comment, however, it doesn't show up the latest comment after updated. Sometimes, duplicate comments also will be saved. What's wrong with this code? Thanks.
Regards
Alex
<%@ Control Language="C#" Inherits="Everest.CmsServices.MvcHelper.CmsUserControl" %>
<script runat="server" type="text/C#">
protected override void Render(HtmlTextWriter writer)
{
var context = ViewContext.RequestContext.HttpContext;
var form = context.Request.Form;
if (!string.IsNullOrEmpty(form["comment"]) )
{
var comment = new NameValueCollection();
comment["comment"] = form["comment"];
var parentUUID = (Guid)this.GetContent("News")["UUID"];
ContentService.AddSubContent(parentUUID, "Comment", context.Request.Cookies["Access"]["ScreenName"].ToString(), comment, context.Request.Files, true, null);
}
base.Render(writer);
}
</script>
<div style="text-align:center;">
<h1 class="site_logo"><a href="index.html"><img style="width:310px" src="/template/webapp/binaryresource/mpaper_new/images/logo-banner.jpg" alt="mpaper.tv" /></a></h1>
</div>
<div style="text-align:center;">
<% foreach (var item in this.ContentService.GetAttachments((int)(this.GetContent("News")["ContentId"])) as IEnumerable<FileInContent>)
{ %>
<img style="width:310px" src="<%=item.FileUrl %>" />
<% } %></div>
<div style="text-align:left;" >
<div style="font-weight:900; margin: 15px 15px 0 15px; font-size:160%;"><%=this.GetContent("News")["Title"]%></div>
<br />
<div style="margin: 0 15px; font-size:120%;"><%= this.GetContent("News")["Content"]%></div>
<br />
<ul>
<% = ViewData["Tweet"] %>
</ul>
</div>
<%foreach (var item in this.GetSubContents("News", "comment"))
{
Response.Write(item["Comment"].ToString() +"<BR/>");
}
%>
<% if (ViewContext.RequestContext.HttpContext.Request.Cookies["access"] != null) { %>
<FORM METHOD="POST" ACTION="#" >
<TEXTAREA rows="3" name="comment"></TEXTAREA>
<input type="submit" value="Submit" />
</FORM>
<% } else { %>
<%=Html.PageLink("Login", "TestLogin", new {})%>
<% }%>