View Single Post
  #4 (permalink)  
Old October 24th, 2006, 02:11 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Peter,

If you want to have different shops under the same domain, you need some way to determine the current "shop" in your code. One way to do this is to use a common base page that all your pages derive from. That's the way I designed a similar shop solution that was the basis for the (simplified) shop in the book.

In your App_Code folder, add a class called BasePage for example, that inherits from System.Web.UI.Page, like this:
Code:
Public Class BasePage
  Inherits System.Web.UI.Page
End Class
Then make your pages in the site inherit from that BaseClass instead of from System.Web.UI.Page (which is the default).

Next, give this BasePage class a read-only property like CurrentSite. This can be an Integer, or an enumeration for example that represents the current site. In the getter for this property, look at the current path, and based on something like /Site1/ or /Site2/ return the right shop number.

Next, in the same BaseClass, in the OnPreInit event you can (if that's a requirement) dynamically switch the MasterPage or the Theme to give each site a unique visual appearance.

Another thing you need to take into account is displaying the right products. However, with the CurrentSite property on the BasePage you can always see what site you're in and base your queries on that. That is, pass something like Me.CurrentSite to select methods that return your products.

You need to apply the same stuff to the Management section, so you can add products for the various shops.

Of course there's more stuff to take into account, but it's difficult to recommend anything without knowing what route you're going to take. I'll be more than happy to provide more help when you start with this and run into unforeseen issues....

Suggested reading for a BasePage and switching MasterPages:

ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps
Establish common ASP.NET page features through inheritance


Cheers,


Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Reptile by Nine Inch Nails (Track 12 from the album: The Downward Spiral) What's This?