Structure of website

D

David

Hi all,

using 1.1

I am creating a dynamic menu structure for my site, however, I may refer to
the structure many times within a page. This would be fine if I was doing it
all in the codebehind of the page, but I am trying to create seperate tiers
for seperate areas. The menu structure I suppose is a middle tier...

The menu is built using a recursive function to build the tree. My page
would normally call a seperate class and function to build the menu. This
would effectively mean that every time I wanted to use the menu in whatever
classes elsewhere in my page, I would have to create the menu from scratch
again to work with it.

This is what I am trying to avoid, as it can be an expensive process to call
the database for every operation.

To throw more confusion into the pot, my page codebehind is derived from my
own class, which is in turn derived from system.web.ui.page. This means that
the codebehind for the page itself has very little code in it, all the work
being done in my derived class.

On the page itself, I have custom controls and user controls. The user
controls also work like the pages where the codebehind is derived from my
derived class, which derives from usercontrol. The custom and user controls
must also be able to work with the menu class.

Where would be the best place to set up the initial menu, so that my derived
page, the page codebehind and my controls can all interact with it, without
having to build the menu each time?

Thanks for your time. If this is a little confusing, please ask me to
attempt to make it clearer.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
G

Guest

Hi,

I am guessing that I didn't phrase this question easily...

Basically, I want to have a base class that on the first call to the page,
creates and populates a menu object.

When I need to refer to the menu at any time within the page (such as
creating a menu tree or finding which page I am on through following the menu
tree, or creating a breadcrumb trail), I don't want to have to create a menu
class for each instance.

What may add to the confusion is that my page, user controls and custom
controls derive from my own base classes, so there is an extra layer of
confusion. I would like my page base class to be able to know about the menu
(which can pass it to the page class), and my UCs base class to know about
it, which can pass to the UC codebehind.

I don't mind creating the menu for each page, but I really only want to
create it once, because it uses a database call, I don't want to have an
expensive process for each use of it.

All help is appreciated.

Regards,
Dave Colliver.
http://www.DerbyFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
 
D

David

Hi all,

I am really struggling with this still. Any help would be appreciated...

I don't know if this will work, I am thinking along the lines of ...

In my base page, in the page_init (override), create a new instance of the
class that calls the database for the menu, and create the menu structure
into a dataset (or my own structure)

Then, in my controls (or even the page itself), open the dataset (or my own
structure) that has been created from the base page.

So, for example, I have a data layer... if I have a property in the
datalayer class that stores my dataset, that I populate on the page_init,
when I come to use it in the controls, can I do something as simple as...

MyMenu = this.Menu as MyClass.Menu;

(I am using c#, .net 1.1)

Will it then access the already created Menu?

If it is likely to work, I am not sure of the way to code it. Any help here
is appreciated.

If you don't think it will work the way outlined above, but know of another
way, again, any help is appreciated.

The idea is to just call the database once for something that is likely to
be expensive to create. I don't need it on application or session level.
Page level will be fine. The problem with application or session level is
that if any changes are made to the menu structure, they won't be visible
until it has timed out.

Thanks for your time.

Best regards,
Dave Colliver.
http://www.CardiffFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top