469,326 Members | 1,229 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

Dynamic Controls Without Doubling Processing Overhead

When a ASPX page is created with dynamic controls based on what the
user is doing the programmer must recreate the dynamic controls again
on PostBack in the Page_Load so that it's events are wired and are
called like a static control.

Here is the problem that I need to solve. The processing overhead
that occurs to determine what dynamic controls need to be added
involves business logic and a query or queries of data in a sql server
database. I would like to stop querying the database on every
PostBack to cut the processing in half (once for the page_load wireup
and once for the creation of new dynamic controls on the page to be
sent back to the user).

Imagine a web page that creates an table with embeded asp hyperlink
buttons based on a user's selection of criteria in a combo box. The
hyperlink has an event handler that does stuff. If the user clicks on
a hyperlink it will not fire the event handler unless the entire table
with hyperlinks is re-created on page_load. This re-creation of the
entire table is a waste of processing just to execute the one
hyperlink's event.

Any ideas on how to save this processing?
Nov 18 '05 #1
2 2311
Dave,
Quickly I can think of two options.
First off, when you run your business logic and determine which controls
need to be dynamically loaded, you can save the result of that business
logic in the viewstate, which @ postback you can retrieve and reload the
controls. True, you still need to reload all the controls, but from what
you are saying, the performance issue comes with the business logic not the
reloading.

Alternatively, on postback you can take a peak at __EVENTTARGET in
Request.Form (Request.Form["__EVENTTARGET"]) and from that you might be able
to skip reloading the controls and skip directly to the hyperlink event (it
won't get called, but you'll know which control fired the postback and can
call the correct event).

Karl

"Dave Williamson" <dw*********@ivsi.com> wrote in message
news:b8**************************@posting.google.c om...
When a ASPX page is created with dynamic controls based on what the
user is doing the programmer must recreate the dynamic controls again
on PostBack in the Page_Load so that it's events are wired and are
called like a static control.

Here is the problem that I need to solve. The processing overhead
that occurs to determine what dynamic controls need to be added
involves business logic and a query or queries of data in a sql server
database. I would like to stop querying the database on every
PostBack to cut the processing in half (once for the page_load wireup
and once for the creation of new dynamic controls on the page to be
sent back to the user).

Imagine a web page that creates an table with embeded asp hyperlink
buttons based on a user's selection of criteria in a combo box. The
hyperlink has an event handler that does stuff. If the user clicks on
a hyperlink it will not fire the event handler unless the entire table
with hyperlinks is re-created on page_load. This re-creation of the
entire table is a waste of processing just to execute the one
hyperlink's event.

Any ideas on how to save this processing?

Nov 18 '05 #2
In addtion to Karl's post, you might look into caching of your data using
one of the ASP.NET caching methods. The can save trips to the server
without increasing the bandwidth requirements of ViewState.

--
Rocky Moore
www.HintsAndTips.com / Share your tips - Earn rewards
www.MyQuickPoll.com / 2004 Election poll ID #33
www.GotTheAnswerToSpam.com / Block virtually all spam email
www.RJSoft.com/Products/RJContentPanel/ - Free web user template content
control!
"Dave Williamson" <dw*********@ivsi.com> wrote in message
news:b8**************************@posting.google.c om...
When a ASPX page is created with dynamic controls based on what the
user is doing the programmer must recreate the dynamic controls again
on PostBack in the Page_Load so that it's events are wired and are
called like a static control.

Here is the problem that I need to solve. The processing overhead
that occurs to determine what dynamic controls need to be added
involves business logic and a query or queries of data in a sql server
database. I would like to stop querying the database on every
PostBack to cut the processing in half (once for the page_load wireup
and once for the creation of new dynamic controls on the page to be
sent back to the user).

Imagine a web page that creates an table with embeded asp hyperlink
buttons based on a user's selection of criteria in a combo box. The
hyperlink has an event handler that does stuff. If the user clicks on
a hyperlink it will not fire the event handler unless the entire table
with hyperlinks is re-created on page_load. This re-creation of the
entire table is a waste of processing just to execute the one
hyperlink's event.

Any ideas on how to save this processing?

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Nathan Bloomfield | last post: by
3 posts views Thread by Leo J. Hart IV | last post: by
4 posts views Thread by pbb | last post: by
11 posts views Thread by toton | last post: by
9 posts views Thread by Tarscher | last post: by
reply views Thread by Eniac | last post: by
4 posts views Thread by =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.