473,714 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Menu ascx - use database? Best practice?

Hello -

I have a book that illustrates pulling menu items from a Sql Server table
into an ascx via a stored procedure. Is this something that is done in the
real world?

I do like the effect when viewing it in the source code, however, because it
doesn't show the complete path to the file. (I'm talking about Internet
Explorer click View, click source code.)

It does seem like it causes an undue amount of trips to the server, although
the pages themselves in my application require a trip to the server in many
cases.

Can anyone give me any reasons why or why not to do it this way?

--
Sandy
Nov 19 '05 #1
6 3234
Sandy wrote:
Hello -

I have a book that illustrates pulling menu items from a Sql Server table
into an ascx via a stored procedure. Is this something that is done in the
real world?

I do like the effect when viewing it in the source code, however, because it
doesn't show the complete path to the file. (I'm talking about Internet
Explorer click View, click source code.)

It does seem like it causes an undue amount of trips to the server, although
the pages themselves in my application require a trip to the server in many
cases.

Can anyone give me any reasons why or why not to do it this way?

Does the menu change (is it really something that needs to be dynamic)?
If not stick it into a control with the values, otherwise, if you need
it to be dynamic you pretty much have to re-read it each time.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Nov 19 '05 #2
Hi Curt_C -

Thanks for your response! I was thinking about just using hyperlinks and
putting them into a user control as an alternative.

Your statement "If not stick it into a control with the values" . . . can
you be more specific?

--
Sandy
"Curt_C [MVP]" wrote:
Sandy wrote:
Hello -

I have a book that illustrates pulling menu items from a Sql Server table
into an ascx via a stored procedure. Is this something that is done in the
real world?

I do like the effect when viewing it in the source code, however, because it
doesn't show the complete path to the file. (I'm talking about Internet
Explorer click View, click source code.)

It does seem like it causes an undue amount of trips to the server, although
the pages themselves in my application require a trip to the server in many
cases.

Can anyone give me any reasons why or why not to do it this way?

Does the menu change (is it really something that needs to be dynamic)?
If not stick it into a control with the values, otherwise, if you need
it to be dynamic you pretty much have to re-read it each time.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

Nov 19 '05 #3
Sandy,

Depends on your need if the menu items don't change very often then you can
always use the Cache object to store them and then invalidate the cache.

Or alternatively you could always use an XML file to store your menu items
and parse the XML and them dynamically that way.

We use both SQL and XML files where I work. Both are practical but you do
want to watch your round trips to the database.

Russ

"Sandy" <Sa***@discussi ons.microsoft.c om> wrote in message
news:EB******** *************** ***********@mic rosoft.com...
Hi Curt_C -

Thanks for your response! I was thinking about just using hyperlinks and
putting them into a user control as an alternative.

Your statement "If not stick it into a control with the values" . . . can
you be more specific?

--
Sandy
"Curt_C [MVP]" wrote:
Sandy wrote:
> Hello -
>
> I have a book that illustrates pulling menu items from a Sql Server
> table
> into an ascx via a stored procedure. Is this something that is done in
> the
> real world?
>
> I do like the effect when viewing it in the source code, however,
> because it
> doesn't show the complete path to the file. (I'm talking about
> Internet
> Explorer click View, click source code.)
>
> It does seem like it causes an undue amount of trips to the server,
> although
> the pages themselves in my application require a trip to the server in
> many
> cases.
>
> Can anyone give me any reasons why or why not to do it this way?
>

Does the menu change (is it really something that needs to be dynamic)?
If not stick it into a control with the values, otherwise, if you need
it to be dynamic you pretty much have to re-read it each time.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

Nov 19 '05 #4
Hi Russ -

Thanks for your response. My menu items don't change very often. Could you
be more specific on "use the Cache object to store them and then invalidate
the cache"?
--
Sandy
"Russ Farris" wrote:
Sandy,

Depends on your need if the menu items don't change very often then you can
always use the Cache object to store them and then invalidate the cache.

Or alternatively you could always use an XML file to store your menu items
and parse the XML and them dynamically that way.

We use both SQL and XML files where I work. Both are practical but you do
want to watch your round trips to the database.

Russ

"Sandy" <Sa***@discussi ons.microsoft.c om> wrote in message
news:EB******** *************** ***********@mic rosoft.com...
Hi Curt_C -

Thanks for your response! I was thinking about just using hyperlinks and
putting them into a user control as an alternative.

Your statement "If not stick it into a control with the values" . . . can
you be more specific?

--
Sandy
"Curt_C [MVP]" wrote:
Sandy wrote:
> Hello -
>
> I have a book that illustrates pulling menu items from a Sql Server
> table
> into an ascx via a stored procedure. Is this something that is done in
> the
> real world?
>
> I do like the effect when viewing it in the source code, however,
> because it
> doesn't show the complete path to the file. (I'm talking about
> Internet
> Explorer click View, click source code.)
>
> It does seem like it causes an undue amount of trips to the server,
> although
> the pages themselves in my application require a trip to the server in
> many
> cases.
>
> Can anyone give me any reasons why or why not to do it this way?
>
Does the menu change (is it really something that needs to be dynamic)?
If not stick it into a control with the values, otherwise, if you need
it to be dynamic you pretty much have to re-read it each time.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com


Nov 19 '05 #5
You basically have two decisions to make, and two options for the
implementation of each:
DECISION 1: Implement menu as (1) a user control OR (2) put it into each
page by itself (i.e., not encapsulated in a user control).
DECISION 2: Create the menu items as (1) hard-coded into the menu's HTML
definition OR (2) dynamically load the menu items into the menu at runtime.

Any combination of these decisions/implementations can happen. Which you go
with can be determined by a number of factors.
I have a book that illustrates pulling menu items from a Sql Server table
into an ascx via a stored procedure. Is this something that is done in
the real world? << Yes - all the time.
I do like the effect when viewing it in the source code, however, because
it doesn't show the complete path to the file. << Not sure what you're talking about... as the browser MUST have a complete
path, otherwise it can't possibly retrieve the file from your Web server.
It does seem like it causes an undue amount of trips to the server << .... and Can anyone give me any reasons why or why not to do it this way?<<
I'll address both:
Yes - and that's what Russ' post was addressing. If you are loading the menu
items dynamically, then the code that loads the items into the menu can
first retrieve the menu items from any number of locations, including the
database, an XML file, or any number of objects loaded in any number of
locations in memory (Application state, session state, the Cache object,
etc - each with its benefits and drawbacks). For performance reasons you
would want to reduce number of trips to the database, and you wouldn't want
to be reading an XML file every time either. That's why you'd want to pull
the menu items from some location in memory. The Cache object is a great
place to do this - but you'd have to make sure that your code doesn't assume
the data is there (i.e., have it look to the Cache first, then if it's not
there, then go to the database OR xml file; which ever is persisting the
items). You'd also have to take specific steps to ensure that stale data
doesn't exist in the Cache (i.e., you don't want to update the database or
XML file that is holding the menu items without ALSO invalidating the
Cache - which is a big way to say "Clear the Cache").

Remember, you don't have to make it this complex. If you have a simple Web
site with just a few pages that change infrequently, then one
straight-forward (yet flexible) way to go would be to store the menu items
in an XML file and then load those at runtime into the menu.

If you have a more sophisticated Web site with much higher traffic levels
and more complex needs (like showing different menus depending on whether
the user is logged in or not, and if they are, then showing them certian
menu items depending on what they have permissions to see), then you would
certainly benefit from storing the menu items in a database (and not
hard-coding them or storing them in an XML file). Then, for performance
reasons you'd want to have the menu's code behind logic retrieve the menu
items from memory (and go to the database only if not available in memory).

Regardless of the simplicity or complexity of your site, it would almost
always be a good idea to put the menu in a user control and not hard-code it
into each aspx page (even if you have just a few pages).

HTH

-F

-HTH

"Sandy" <Sa***@discussi ons.microsoft.c om> wrote in message
news:D4******** *************** ***********@mic rosoft.com... Hi Russ -

Thanks for your response. My menu items don't change very often. Could
you
be more specific on "use the Cache object to store them and then
invalidate
the cache"?
--
Sandy
"Russ Farris" wrote:
Sandy,

Depends on your need if the menu items don't change very often then you
can
always use the Cache object to store them and then invalidate the cache.

Or alternatively you could always use an XML file to store your menu
items
and parse the XML and them dynamically that way.

We use both SQL and XML files where I work. Both are practical but you
do
want to watch your round trips to the database.

Russ

"Sandy" <Sa***@discussi ons.microsoft.c om> wrote in message
news:EB******** *************** ***********@mic rosoft.com...
> Hi Curt_C -
>
> Thanks for your response! I was thinking about just using hyperlinks
> and
> putting them into a user control as an alternative.
>
> Your statement "If not stick it into a control with the values" . . .
> can
> you be more specific?
>
> --
> Sandy
>
>
> "Curt_C [MVP]" wrote:
>
>> Sandy wrote:
>> > Hello -
>> >
>> > I have a book that illustrates pulling menu items from a Sql Server
>> > table
>> > into an ascx via a stored procedure. Is this something that is done
>> > in
>> > the
>> > real world?
>> >
>> > I do like the effect when viewing it in the source code, however,
>> > because it
>> > doesn't show the complete path to the file. (I'm talking about
>> > Internet
>> > Explorer click View, click source code.)
>> >
>> > It does seem like it causes an undue amount of trips to the server,
>> > although
>> > the pages themselves in my application require a trip to the server
>> > in
>> > many
>> > cases.
>> >
>> > Can anyone give me any reasons why or why not to do it this way?
>> >
>> Does the menu change (is it really something that needs to be
>> dynamic)?
>> If not stick it into a control with the values, otherwise, if you need
>> it to be dynamic you pretty much have to re-read it each time.
>>
>> --
>> Curt Christianson
>> site: http://www.darkfalz.com
>> blog: http://blog.darkfalz.com
>>


Nov 19 '05 #6
Thanks All!!
--
Sandy
"Sandy" wrote:
Hello -

I have a book that illustrates pulling menu items from a Sql Server table
into an ascx via a stored procedure. Is this something that is done in the
real world?

I do like the effect when viewing it in the source code, however, because it
doesn't show the complete path to the file. (I'm talking about Internet
Explorer click View, click source code.)

It does seem like it causes an undue amount of trips to the server, although
the pages themselves in my application require a trip to the server in many
cases.

Can anyone give me any reasons why or why not to do it this way?

--
Sandy

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
3944
by: Don G | last post by:
Within the menu for my site, I have inserted 'class="current"' within the link for the current page. So the link looks somthing link: <li><a href="index.php" class="current">Home</a></li> The css for formatting the menu links is: #menu a:hover { background-color: #E00080; color: white;
0
1246
by: naijacoder naijacoder | last post by:
Here goes the scenario.. The intranet is using windows Auth integrated wih Active Directory. Which is fine and all the appropriate Roles/Groups are set. When a user clicks on a button on a page he/she is prompted and logs on and authorisation takes place and he gets redirected to the page depending on the GROUP/ROLES they belong to in the active directory. On the pages they have treeview webcontrol as a menu structure and the
4
1656
by: Milsnips | last post by:
hi there, Can someone help me out with some example code (VB.NET) here that i need: i would like to programatically check my ASP.NET web application and return a list of all the ASPX and ASCX pages in the project, then return them in an string array, eg. name : type ("default.aspx : ASPX") i figured if i use the io.directory, it might even return items which could be excluded from the project, which i dont want, thats why i think it...
1
1378
by: John | last post by:
Hi, I've decided to try to reduce duplicate code and simplify a seriously complicated page I have by using web user controls. My problem is; one of the controls contained within my new ascx, needs to update the page when ever it changes. In appreciation for encapsulation, I do not want to call a page level javascript function from an internal control ... I want it as self contained as possible.
3
1219
by: WT | last post by:
I use Menu navigation control in an ascx, the Menu if filled with Menuitems during Load event. Sub-MenuItems are added to the ChildItems collection. But on the display the behavior of menu is not working: everything is written in the same column, without any level considerations. When I move mouse on dynamics elements, they disappear and never come back. Is there a problem using Menu in ascx, is there a conflict in javascript. Is it...
1
7160
by: xpnctoc | last post by:
Here's the 30,000-ft. view: I wrapped an asp:Menu control in an ascx control. When I try to dynamically populate the menu in the ascx control, the items appear, but clicking on them fails to trigger the MenuItemClick event handler. However, if I statically declare the menu items in the .ascx page, everything is fine. Any ideas? Here's the details: My ascx page: <%@ Control Language="VB" AutoEventWireup="false"...
3
2110
by: John | last post by:
Hi there, I was reading an article (http://avenuea-razorfish.com/articles/TheAll-MenuNavigation_Turbek.pdf) on 'all-menu navigation' and I'd like to try and implement this in my site. Can anyone recommend how to get started? Is there an Ajax control available for this or would more a basic javascript work just as well. I'm assuming I just need a div element that is shown on a mouse over, but I'm not sure how to go about aligning all...
1
2223
by: Yin99 | last post by:
I have a Menu control that currently changes the view on a MultiView. Works, but I was wondering if there is any way to load separate pages in each view via Menu? Ex: (Allows user to select view in Multiview)
3
2146
by: win | last post by:
I've create menu in a webform. <asp:Menu ID="Menu1" runat="server" CssClass="toolbar" Orientation="Horizontal"> <Items> <asp:MenuItem Text="Master" Value="Master"> <asp:MenuItem Text="Maintenance" Value="Maintenance"> <asp:MenuItem Text="Employee Maintenance " Value=" Employee Maintenance ">
0
8801
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8707
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9015
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7953
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4464
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2520
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2110
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.