I typically render comments in a simple repeater.
I have a social app which requires nested comments (being able to comment on a comment).
So I have objects which look like this:
class Comment
{
public string Body { get; set; }
public User Creator { get; set; }
public List<Comment> ChildComments { get; set; }
}
Can I use nested repeaters? Is that even a good idea? Do I need to pre-render the HTML in a recursive loop and send it to a literal?
Not sure what to do with this one.
You could use an HTML source block, then iterate through the comments, adding a <DIV> for each comment begin, then after each comment, call the iterator on the nest list for that comment, then add the closing </DIV>
It sounds like you need to use UserControls here. Make a user control for a comment that knows how to render itself, and has 0...N other CommentUserControls (possibly rendered using a repeater). This effectively ends up with nested repeaters (kinda) but by encapsulating one of the repeaters in a UserControl it should make it less messy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With