Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 12th, 2006, 03:43 PM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Wrox blog suggestions

I've been considering doing some changes to the Wrox Blog project, but I'm unsure how to approach it.

I would like the blog to be displayed over the comments when show comments are pressed with add comments below the comments already made.
Something like this:

Blog
---
comment
---
comment
--
add comments
---

Would it be possible, or a good approach to make nested panels.
Or is it possible to put a particular blog + it's comment in a new file and call at panels across files. In this case is it possible to make changes like show/hide panel in one usercontrol file in another usercontrol file.
for example if I move the show/add comment panels to BlogComments.ascx. Would I still be able to access these panels from BlogEntries.ascx.

Another tweak would be to display comments[5] to show how many comments are made in place of the add and show comments as is in the modified project now. I guess this could be handled with it's own stored procedure.

thanks

regards, Nakori

  #2 (permalink)  
Old June 13th, 2006, 01:56 PM
Imar's Avatar
Wrox Author
Points: 71,768, Level: 100
Points: 71,768, Level: 100 Points: 71,768, Level: 100 Points: 71,768, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,031
Thanks: 80
Thanked 1,580 Times in 1,557 Posts
Default

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
  #3 (permalink)  
Old June 15th, 2006, 03:06 PM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks, I have implemented something like your suggestion now.
(For my own part, no plans to publish anything just yet)

One more question though..

I reused BlogEntriesFilter control on a new page BlogSingleEntry.aspx.

In public string GetNavigateUrl( object categoryId )
I have replaced this line in both BlogEntries and BlogEntriesFilter
  //return Request.CurrentExecutionFilePath + "?" + queryString;
  return "~/Default.aspx?" + queryString;

Since using calendar and category control from my new page with its controls will render BlogSingleEntry.aspx?= .. rather than default.aspx that have BlogEntries.ascx.

Since you did not hardcode the path yourself, is there anything that do not make this replacement an elegant solution to this?


  #4 (permalink)  
Old June 15th, 2006, 04:35 PM
Imar's Avatar
Wrox Author
Points: 71,768, Level: 100
Points: 71,768, Level: 100 Points: 71,768, Level: 100 Points: 71,768, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,031
Thanks: 80
Thanked 1,580 Times in 1,557 Posts
Default

Hi nakori,

No, in your solution, hard coding the path is fine.

Again, this had to do with design issues. The Blog from the book is designed in such a way, that it can be used in any app and any page. Since there's no way I can guess the name of the page where the control is used, I used CurrentExecutionFilePath. At run time, this returns the page name where the control is used. So, this could be anything from Default.aspx to SomeWeirdPageName.aspx. This makes for a flexible solution, allowing you to rename or move pages.

However, if you're using the Blog controls in a fixed application, using ~/Default.aspx will work fine, as you know that's the name of the containing page.

Does that answer your question?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrox Blog in C# madAlan BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 22 June 12th, 2011 04:09 AM
Wrox Blog tblessed23 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 16 May 14th, 2007 04:08 PM
Wrox Blog: Viewing individual blog entries Tawanda BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 7 May 7th, 2007 12:06 PM
Login for Wrox Blog danielson BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 March 20th, 2007 02:12 PM
Wrox Blog - Multiple Categories suggestions madAlan BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 January 28th, 2007 05:39 PM



All times are GMT -4. The time now is 05:26 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.