473,836 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User Control Implementation: Could It Be More Efficient?

I have a non trivial ASP.NET Web application that implements its navigation
system via a user control (menu.ascx) placed on every page.

It is important to note that the user control that hosts the menu is
injected into every page at runtime when the page is requested (i.e., it's
not declared in any ASPX).

The user control contains a menu that is dynamically populated and styled at
runtime (fwiw: it's ComponentArt's Menu for ASP.NET - but that's irrellevant
to this question)

The data for the menu is retrieved from a SQL Server database - and loaded
into the menu at runtime during the Page_Load event procedure of menu.ascx.

I have implemented security such that different DataSets are used to
construct the menu: If the current user is NOT logged in, then they get a
standard menu which is stored in the Application state. But once the user
logs in, then they get a user-specific menu - with its supporting DataSet
stored in their Session.

The application code always attempts to retrieve the menu's DataSet from
either the Application state or the Session - and hittis the db only if not
found in one of those places.

This all works very well - and production runtime performance is acceptable.
But I want to do better.

While I have reduced db hits as much as possible, the property values for
the menu are set on *every* page request (during the page_load event of
menu.ascx). This seems like it is or should be totally unnecessary. I would
like to set the menu properties only once and then never again if possible
(with the only exception being that an unauthenticated user logs in - in
which they would get new menu properties - which should then be in effect
for the duration of their session)

ViewState, AFAIK, is how we maintain control property settings between page
requests. But I'm not sure it will help me here. To EnableViewState on
either the PlaceHolder into which I'm injecting the user control, or on the
user control would not help me in this case because the user control is
injected into each page at runtime (via a PlaceHolder) - or so I think. If
I'm correct, then a newly requested page would not have the opportunity to
have the menu's viewstate because only previously-opened pages would have
the menu's ViewState information (and not the currently/newly-opened page).
You can see that this is where I'm getting a little fuzzy on what's going on
here with ViewState as it relates to my application and its menu and hosting
user control.

So - I would appreciate it if someone could shed some light on what's going
on here with respect to ViewState and how I might be able to continue with
my existing architecture (of injecting into each page the menu's user
control at runtime) AND NOT have to continue setting all of the menu's
properties on every page request - and ideally only once or twice per
session).

Thanks!
Nov 19 '05 #1
7 1945
Have you looked into using the Cache object ?
The situation you describe sounds tailor-made for it.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
=============== =======

"Smithers" <A@B.com> wrote in message news:eu******** ******@tk2msftn gp13.phx.gbl...
I have a non trivial ASP.NET Web application that implements its navigation system via a
user control (menu.ascx) placed on every page.

It is important to note that the user control that hosts the menu is injected into every
page at runtime when the page is requested (i.e., it's not declared in any ASPX).

The user control contains a menu that is dynamically populated and styled at runtime
(fwiw: it's ComponentArt's Menu for ASP.NET - but that's irrellevant to this question)

The data for the menu is retrieved from a SQL Server database - and loaded into the menu
at runtime during the Page_Load event procedure of menu.ascx.

I have implemented security such that different DataSets are used to construct the menu:
If the current user is NOT logged in, then they get a standard menu which is stored in
the Application state. But once the user logs in, then they get a user-specific menu -
with its supporting DataSet stored in their Session.

The application code always attempts to retrieve the menu's DataSet from either the
Application state or the Session - and hittis the db only if not found in one of those
places.

This all works very well - and production runtime performance is acceptable. But I want
to do better.

While I have reduced db hits as much as possible, the property values for the menu are
set on *every* page request (during the page_load event of menu.ascx). This seems like
it is or should be totally unnecessary. I would like to set the menu properties only
once and then never again if possible (with the only exception being that an
unauthenticated user logs in - in which they would get new menu properties - which
should then be in effect for the duration of their session)

ViewState, AFAIK, is how we maintain control property settings between page requests.
But I'm not sure it will help me here. To EnableViewState on either the PlaceHolder into
which I'm injecting the user control, or on the user control would not help me in this
case because the user control is injected into each page at runtime (via a
PlaceHolder) - or so I think. If I'm correct, then a newly requested page would not have
the opportunity to have the menu's viewstate because only previously-opened pages would
have the menu's ViewState information (and not the currently/newly-opened page). You can
see that this is where I'm getting a little fuzzy on what's going on here with ViewState
as it relates to my application and its menu and hosting user control.

So - I would appreciate it if someone could shed some light on what's going on here with
respect to ViewState and how I might be able to continue with my existing architecture
(of injecting into each page the menu's user control at runtime) AND NOT have to
continue setting all of the menu's properties on every page request - and ideally only
once or twice per session).

Thanks!

Nov 19 '05 #2
With all due respect - have you actually read my OP?

The whole issue centers around reducing the number of times I set properties
in a user control that is injected into each page at runtime - NOT reducing
db hits. I'm already caching data - just not in the Cache object because it
is not the best place, IMHO, for user-specific values.

If I missed something about how the Cache can be helpful to my particular
situaion - then can you please be a bit more specific?

-S


"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:ex******** ******@TK2MSFTN GP14.phx.gbl...
Have you looked into using the Cache object ?
The situation you describe sounds tailor-made for it.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
=============== =======

"Smithers" <A@B.com> wrote in message
news:eu******** ******@tk2msftn gp13.phx.gbl...
I have a non trivial ASP.NET Web application that implements its
navigation system via a user control (menu.ascx) placed on every page.

It is important to note that the user control that hosts the menu is
injected into every page at runtime when the page is requested (i.e.,
it's not declared in any ASPX).

The user control contains a menu that is dynamically populated and styled
at runtime (fwiw: it's ComponentArt's Menu for ASP.NET - but that's
irrellevant to this question)

The data for the menu is retrieved from a SQL Server database - and
loaded into the menu at runtime during the Page_Load event procedure of
menu.ascx.

I have implemented security such that different DataSets are used to
construct the menu: If the current user is NOT logged in, then they get a
standard menu which is stored in the Application state. But once the user
logs in, then they get a user-specific menu - with its supporting DataSet
stored in their Session.

The application code always attempts to retrieve the menu's DataSet from
either the Application state or the Session - and hittis the db only if
not found in one of those places.

This all works very well - and production runtime performance is
acceptable. But I want to do better.

While I have reduced db hits as much as possible, the property values for
the menu are set on *every* page request (during the page_load event of
menu.ascx). This seems like it is or should be totally unnecessary. I
would like to set the menu properties only once and then never again if
possible (with the only exception being that an unauthenticated user logs
in - in which they would get new menu properties - which should then be
in effect for the duration of their session)

ViewState, AFAIK, is how we maintain control property settings between
page requests. But I'm not sure it will help me here. To EnableViewState
on either the PlaceHolder into which I'm injecting the user control, or
on the user control would not help me in this case because the user
control is injected into each page at runtime (via a PlaceHolder) - or so
I think. If I'm correct, then a newly requested page would not have the
opportunity to have the menu's viewstate because only previously-opened
pages would have the menu's ViewState information (and not the
currently/newly-opened page). You can see that this is where I'm getting
a little fuzzy on what's going on here with ViewState as it relates to my
application and its menu and hosting user control.

So - I would appreciate it if someone could shed some light on what's
going on here with respect to ViewState and how I might be able to
continue with my existing architecture (of injecting into each page the
menu's user control at runtime) AND NOT have to continue setting all of
the menu's properties on every page request - and ideally only once or
twice per session).

Thanks!


Nov 19 '05 #3
re:
I'm already caching data - just not in the Cache object
That's why I asked.
Sorry to have disturbed you.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
=============== =======

"Smithers" <A@B.com> wrote in message news:ua******** ******@TK2MSFTN GP10.phx.gbl... With all due respect - have you actually read my OP?

The whole issue centers around reducing the number of times I set properties in a user
control that is injected into each page at runtime - NOT reducing db hits. I'm already
caching data - just not in the Cache object because it is not the best place, IMHO, for
user-specific values.

If I missed something about how the Cache can be helpful to my particular situaion -
then can you please be a bit more specific?

-S
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:ex******** ******@TK2MSFTN GP14.phx.gbl...
Have you looked into using the Cache object ?
The situation you describe sounds tailor-made for it.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
=============== =======

"Smithers" <A@B.com> wrote in message news:eu******** ******@tk2msftn gp13.phx.gbl...
I have a non trivial ASP.NET Web application that implements its navigation system via
a user control (menu.ascx) placed on every page.

It is important to note that the user control that hosts the menu is injected into
every page at runtime when the page is requested (i.e., it's not declared in any
ASPX).

The user control contains a menu that is dynamically populated and styled at runtime
(fwiw: it's ComponentArt's Menu for ASP.NET - but that's irrellevant to this question)

The data for the menu is retrieved from a SQL Server database - and loaded into the
menu at runtime during the Page_Load event procedure of menu.ascx.

I have implemented security such that different DataSets are used to construct the
menu: If the current user is NOT logged in, then they get a standard menu which is
stored in the Application state. But once the user logs in, then they get a
user-specific menu - with its supporting DataSet stored in their Session.

The application code always attempts to retrieve the menu's DataSet from either the
Application state or the Session - and hittis the db only if not found in one of those
places.

This all works very well - and production runtime performance is acceptable. But I
want to do better.

While I have reduced db hits as much as possible, the property values for the menu are
set on *every* page request (during the page_load event of menu.ascx). This seems like
it is or should be totally unnecessary. I would like to set the menu properties only
once and then never again if possible (with the only exception being that an
unauthenticated user logs in - in which they would get new menu properties - which
should then be in effect for the duration of their session)

ViewState, AFAIK, is how we maintain control property settings between page requests.
But I'm not sure it will help me here. To EnableViewState on either the PlaceHolder
into which I'm injecting the user control, or on the user control would not help me in
this case because the user control is injected into each page at runtime (via a
PlaceHolder) - or so I think. If I'm correct, then a newly requested page would not
have the opportunity to have the menu's viewstate because only previously-opened pages
would have the menu's ViewState information (and not the currently/newly-opened page).
You can see that this is where I'm getting a little fuzzy on what's going on here with
ViewState as it relates to my application and its menu and hosting user control.

So - I would appreciate it if someone could shed some light on what's going on here
with respect to ViewState and how I might be able to continue with my existing
architecture (of injecting into each page the menu's user control at runtime) AND NOT
have to continue setting all of the menu's properties on every page request - and
ideally only once or twice per session).

Thanks!



Nov 19 '05 #4
Have a look at output caching,

This works by caching the result of the render of a page (or control)
then using this,

In win 2003 and IIS 6 this is a kernal level cache and is very quick

Nov 19 '05 #5
Why is it necessary for you to place the menu control on the page at
runtime? Do you need to dynamically remove the menu from the page
under certain conditions?

Bill E.
Hollywood, FL

Nov 19 '05 #6
Thank you very much! I'll take a look.

-S
<ga**********@g mail.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
Have a look at output caching,

This works by caching the result of the render of a page (or control)
then using this,

In win 2003 and IIS 6 this is a kernal level cache and is very quick

Nov 19 '05 #7
<< Why is it necessary for you to place the menu control on the page at
runtime? >>
Because the location of the menu in the aspx and the particular menu to be
implemented can change at runtime depending on a number of runtime
conditions.

-S


<bi********@net scape.net> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Why is it necessary for you to place the menu control on the page at
runtime? Do you need to dynamically remove the menu from the page
under certain conditions?

Bill E.
Hollywood, FL

Nov 19 '05 #8

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

Similar topics

11
1688
by: Lloyd Sheen | last post by:
Is there any one who has actually done this. I have now scanned more web articles about this with the realization that not one of them (including MSDN docs) outlines how to do this. This is beyond frustration. It seems that with every new VS release the documentation falls further behind. What I want to do should be simple but I can find no way to do it with VS with any visual designer support. I thought the 'V' in VS stood for...
2
2423
by: SoftLion | last post by:
what is the difference between component and web user control ? Thanks !
7
3200
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb -- UC/ ----- Classic/
14
1302
by: Prabhudhas Peter | last post by:
Hai, I've Created a User control for example a Button and i've given the font of the text as Bold and compiled it. Now i've used this Usercontrol everywhere in my project. Now i changed the font from Bold Italic to Regular, and also changed the color. now in my project the changes are not inhertied in already placed user control Buttons. but if i place a new button then i can see the latest changes... what can i do to inherit the...
6
4730
by: Ronald S. Cook | last post by:
We have a Windows app that has one main form (a shell, sort of). We then load user controls into a panel on the form depending on what the user has selected. Our current code to unload the existing user control and load the newly selected one is pretty bulky. Every time we add a new user control to the project, we have to add some code in the section where we are loading/unloading. Is there a more dynamic, more efficient way to...
9
4303
by: moondaddy | last post by:
I'm using asp.net 2.0 and c# and would like to share some user control between several websites. these websites are on the same server and have a physical location right next to each other like this: D:\Websites\Website1 D:\Websites\Website2 I'm thinking of putting the controls for sharing in a common directory like this: D:\Websites\CommonControls
4
4480
by: Joseph Geretz | last post by:
Don't get me wrong - I'm a fan of .NET; I am enthusiastic about the richness and elegance of the environment. However, richness and elegance should be dedicated toward making development easier for developers, not more difficult. In many ways this goal is achieved. However, I've run up against one particular area of development, where what should be a trivial excercise is turning out to be much more difficult than it should be. I'm trying...
1
1582
by: =?Utf-8?B?V29ua28gdGhlIFNhbmU=?= | last post by:
Hello All-- Just a general (or perhaps loaded) question - is it considered good or bad practice to use code-behind with a CustomControl.generic.xaml file? For instance, with a control I'm creating, it would be nice to use a DispatchTimer to "ramp up" a value, depending on how long the mouse is held down. Thanks,
1
1401
by: brixdotnet | last post by:
Hi there! I made own user control for displaying and editing content. In Page_Load of this control is checked if user is authorized for editing if so, button for editing is shown, otherwise controll works in display only mode. I want now use this control to add new content. The idea is that in another web form, let's call AddNewContent.aspx there is placed MyContentControl and I want to run in Editing mode with all fields reset to...
0
9820
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
9670
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,...
1
10591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9374
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...
0
6979
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5649
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...
1
4452
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4016
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3115
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.