Click here to Skip to main content
13,252,362 members (59,560 online)
Rate this:
Please Sign up or sign in to vote.
I'm trying to make a forum for my school project for that I've to add questions and then only registered user can answer them or comment. But how can I add commnet option like CodeProject on my website.

I don't know how to manage them in database. The comments also show the username who comment on question/answer. Also how can I check that the question owner is checking the answer and show him/her the button of Answer of question myself. I will highly thankful if someone help me out from this trouble.
Posted 5-Nov-11 5:17am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I assume you know how to set up a database and read/write data from and to it.
This is no easy task. First of all you need to think about how to set up your database. Will you have a table called Question with a detail relation to a table called Comment? Both your Question and your Comment table will need a relation with User. Both need to be aware of the User that created it.
Now in your page you would need to fetch the Question (you probably have a portion of the questions shown on a page and when a user clicks it you know its ID) and every detail Comment. If you are using an ORM such as Entity Framework this will be done for you almost automatically. You just have to show them.
Now for your question you will have to check if the user that is currently viewing the page is the owner of that Question (you did store the UserID in your Question table, right?). If the current viewer is the owner it sees the "Answer question myself" button. You'd have to set this in your code. You could also give the user the ability to edit his own question or comments.

I am not going to show you code since one could write an entire article about this.
And in fact, people have written articles about it.
JumpyForum: Inspired by Code Project Forum / Discussion / Message board[^]
I hope I've given you enough idea's about how to finish your assignment. The implementation is up to you.
For further questions I suggest you speak to your teacher.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171114.1 | Last Updated 5 Nov 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100