Hi there,
Bit late response.... Things are a bit busy here, and very warm... ;) (And the World Championship Soccer is keeping me from working as well).
Anyway, you have a couple of options. The current blog is set up to contain all logic in a few user controls. That makes it easy to incorporate the blog in an
existing application: just drop a few controls on a page, add some business logic files in App_Code and you're pretty much done.
However, if you're extending the blog, and change it into a full application, you may want to change a few things. My colleague has just used the book's Blog to do something similar: make a full blown blog site with a number of additional features.
If you want to be able to manage things a bit better, here's what you could do:
1. Create a page called BlogDetails.aspx
On this page, display a single Blog entry using Label controls.
2. Create a User Control called CommentList.ascx
This control looks at the Query String (for example) and displays the comments that belong to the blog whose ID is passed in the Query String.
3. Create a User Control called AddComment.ascx
This control uses the same Query String ID to hook up the comment to the appropriate Blog entry
(Number 2 and 3 can be retrieved from the User Controls in the Blog mod that you'll find on the CD-ROM.)
Drag the controls from step 2 and 3 on the page from step 1.
This way, you have a single page that you can use to display a blog. The separate controls in turn are used to (selectively if you want) display comments and the possibility to add a comment.
As an alternative, you can make the Blog Details a separate User Control as well, and put that on the Blog Details page too. That way, you have separated out all the functionality to custom controls that you can easily reuse.
Benefit of this is that things are easy to manage; separate functionality is found in separate controls. Also, all you need to pass around in the Query String is the BlogId. Makes for easy hyperlinks in your code.
With regards to the number of comments: together with the Blog entry, you can select the number of comments that belong to the blog entry. There are a number of ways to do this, but here's one example (put this in the sprocBlogEntrySelectSingleItem procedure):
Code:
@id int
AS
SELECT
B.Id,
B.Title,
B.Body,
B.DatePublished,
B.CategoryId,
(SELECT COUNT(*) FROM Comment WHERE BlogEntryId = B.Id) AS NumberOfComments
FROM
BlogEntry B
WHERE
B.Id = @id
Then you can use the column NumberOfComments in your code; for instance, you can create an additional property NumberOfComments on the BlogEntry class.
Does this help? If you have further questions, let me know.
Any chance were going to see this project live some day? It would be nice to see projects from the book used in the real world, right where they belong...
Imar