1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Accessing Comments ID property

Accessing Comments ID property

7 posts, 0 answered
  1. ddblee
    ddblee avatar
    20 posts
    Registered:
    24 Jul 2008
    24 Sep 2008
    Link to this post
    In the CommentItem repeater control inside  ~/Sitefinity/ControlTemplates/Blogs/Modes/ListPageDetail.ascx, I want to display the Comment ID, using a standard label control.

    What's the best way to get that property?

    Thanks!
  2. ddblee
    ddblee avatar
    20 posts
    Registered:
    24 Jul 2008
    25 Sep 2008
    Link to this post
    Still not gotten anywhere on my own, so would appreciate some help.

    Thanks!
  3. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    25 Sep 2008
    Link to this post
    Hi ddblee,

    I toyed with this for awhile, but I'm sorry to report I don't have a solution for you.

    You can add a label to the ControlTemplate easily enough.  However, it's the code-behind that is obviously responsible for doing something with that label. 

    In this case, the code-behind we're talking about is part of the compiled Sitefinity product.  This code is looking for very specific server tags and I don't believe it is looking for a label to populate with a Comment ID.  This means any labels you add, will just sit empty.

    I thought briefly about adding a custom UserControl to the ControlTemplate and using this control to get access to the root Comments' object that is being databound to the other controls.

    I'm not sure this is possible though.  Your only solution might be to create your own custom control for displaying blog posts. 

    Perhaps others have better ideas though...

    Gabe Sumner


  4. ddblee
    ddblee avatar
    20 posts
    Registered:
    24 Jul 2008
    26 Sep 2008
    Link to this post
    Thanks for the response, Gabe.

    Here's why I want to do what I asked about:
    for our implementation of Blogs, we want to record user input around "Was this comment helpful?" and also record reports of inappropriate comments. To facilitate that, we designed an approach involving some tables added to the database, where the comment ID would be the foreign key. So, being able to grab the comment ID is critical.

    However, if there is a cleaner way to achieve the same result within the Sitefinity framework, I'd love to hear it.

    Thanks!
  5. Sonya
    Sonya avatar
    231 posts
    Registered:
    24 Sep 2012
    26 Sep 2008
    Link to this post
    Hi ddblee,

    You could achieve the functionality you desire by adding the highlighted code to
    ~/Sitefinity/ControlTemplates/Blogs/Modes/ListPageDetail.ascx
    <div class="sf_singlePost"
        ... 
    </div> 
     
    <div class="sf_postComments" runat="server" id="postCommentsPlh"
        <sfWeb:BlogCommentsList ID="commentsList" runat="server" CssClass="sf_commentsList"
            <Template> 
            <asp:Repeater ID="commentsRepeater" runat="Server"
        <HeaderTemplate> 
           ... 
        </HeaderTemplate> 
        <ItemTemplate> 
            ID: <%#DataBinder.Eval(Container.DataItem, "ID") %> 
     
            <!-- comment goes here --> 
            <sfWeb:CommentItem Id="anonCommentContainer" runat="server" CssClass="sf_anonymousComment" >  
              ... 
            </sfWeb:CommentItem> 

    Let me know if you need further assistance.

    Best wishes,
    Sonya
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. ddblee
    ddblee avatar
    20 posts
    Registered:
    24 Jul 2008
    17 Oct 2008
    Link to this post
    Hello!

    I need to be able to access this same property from within
    <sfWeb:CommentItem ID="anonCommentContainer" runat="server" CssClass="sf_anonymousComment">
                            <Template>
    ...
                            </Template>
                        </sfWeb:CommentItem>

    But, using the expression you provided, I get an error:
    'Telerik.Cms.Engine.WebControls.CommentItem.CommentContainer' does not contain a definition for 'DataItem' and no extension method 'DataItem' accepting a first argument of type 'Telerik.Cms.Engine.WebControls.CommentItem.CommentContainer' could be found (are you missing a using directive or an assembly reference?)    C:\tribaldev\lowes\lci\Sitefinity\ControlTemplates\Blogs\Modes\ListPageDetail.ascx

    How would I re-work this expression to resolve the ID from within the <Template> node?

    Thanks!

  7. Sonya
    Sonya avatar
    231 posts
    Registered:
    24 Sep 2012
    24 Oct 2008
    Link to this post
    Hello ddblee,

    Please excuse us for the delay of our response. The container item is not accessible from within a comment item - it is private. So, unfortunately, we could not suggest any solution for this request.

    Regards,
    Sonya
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
7 posts, 0 answered