Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Add subcontent but duplicate record sometimes
hnchan
#1 Posted : Sunday, June 27, 2010 2:05:48 PM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 5/16/2010(UTC)
Posts: 36
Location: HK
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 {})%>
<% }%>


Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 1.9.5.5 | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.066 seconds.