Reputation: 65248
I am inspecting the html at this site: listverse.com
I see that they have inserted ID numbers in the List Tags such as
<li id="comment-220669">
What is the comment-220669 for. And what are they using it for?
If they are using this ID tag to pass information back to the server. How can i do this using c# asp.net mvc?
Upvotes: 0
Views: 315
Reputation: 3074
Looks like a wordpress blog - with wordpress they use an 'almost' microformat to display posts I think the way the comments are markedup relates to this. As other people say the id provides a way of targetting a particular element using javascript.
Upvotes: 0
Reputation: 641
I think they i have been assign Id on every comment of user, and system used that comment id for any function by ajax call when user press mouse over it, click over that list tag etc...
so at every click event system can find the unique reference
Upvotes: 0
Reputation: 10111
I´m pretty sure it´s an inpage link target so you can point out the comment e.g. http://listverse.com/2009/11/12/top-10-tips-for-urban-exploration/#comment-224593
Upvotes: 8
Reputation: 1847
They are most likely generating those to uniquely identify each comment when they view source as it's not very likely or practical to apply styles this way. They are probably accomplishing this (assuming MVC) by looping through a collection of comments and attaching the CommentID to the id field like so:
<% foreach(var comment in Model) { %>
<li id="comment-<%= comment.CommentID %>">Foo</li>
<% } %>
I highly doubt they are using this to pass any information back to the server (Never tried but I think you could do it by parsing the id attribute with jQuery).
If you need to work with the CommentID for a scenario like this you're better of adding it to a query string that goes to an action method, or populating a hidden field in a form that posts to an action method.
Upvotes: 2