473,395 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

AddOnPreRenderCompleteAsync and dynamically created controls

I'm running into a wall with a custom control that gets populated via
asynchronous I/O. Basically, my control takes its datasource and renders
some controls that have events (OnClick). However, there's the well-known
problem of dynamic controls not firing unless they are created during the
page's initialization, so OnPreRender is too late to create any dynamic
controls. That being the case, how can I populate a control asynchronously
(via Page.AddOnPreRenderCompleteAsync) that has events that can get fired?
Nov 19 '05 #1
4 3249
for events to fire on postback, you need to recreate the dynamic controls at
onint. this means you should use a caching scheme to recreate them on
postback. on a render, you can still add controls on prerender fine (as
there are no postback events to manage).

-- bruce (sqlwork.com)
"Keith Patrick" <ri*******************@nospam.hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
I'm running into a wall with a custom control that gets populated via
asynchronous I/O. Basically, my control takes its datasource and renders
some controls that have events (OnClick). However, there's the well-known
problem of dynamic controls not firing unless they are created during the
page's initialization, so OnPreRender is too late to create any dynamic
controls. That being the case, how can I populate a control
asynchronously (via Page.AddOnPreRenderCompleteAsync) that has events that
can get fired?

Nov 19 '05 #2
Hmm, I can see that working, but it's got some issues that may come up under
heavy usage, performance-wise. In my case, I've got the datasource
retrieval abstracted out to a provider, caching included such that any time
I say GetStuff(), it will be from the *current* file contents (cache updates
with the file), and populated on the first call of a page by any user
asynchronously. The thing that's causing me problems doing that is that I
should have logic in the initialization method that's only called when the
data is cached but I'm calling it asynchronously during pre-render when it's
not (and actually, I'm doing this in a masterpage, so I don't even have
access to an OnInit() as well). Things start getting messy when the
external file is changed after render but before postback; the cache is
flushed by the file watcher, so the postback OnInit will now make a
synchronous call to re-fill the cache, bypassing the page's async path.
What would be ideal is to be able to programmatically process postback
events again during the prerender step. I thought I had something along
those lines with Page.RegisterRequiresRaiseEvent, but I misunderstood the
method and wound up getting the last control created being reported as the
sender. Maybe something like Page.PersistForPostBack(...), or if the
ViewState would work with them (I tried and it didn't, although I haven't
ruled out that it's possible)
Nov 19 '05 #3
Heh...scratch that part about not having OnInit in a master page. I'd had
it implemented elsewhere, so it wasn't showing up in AutoComplete. I'm
looking at going back to storing viewstate for the control as my solution;
I'd disabled it to reduce pagesize, but I think it would be more correct for
me to store the stripped down structure in viewstate so I have something
that is consistent with what was build on prerender during rebuilding, thus
avoiding the cache coherency issue when the datasource is changed during
usage.
Nov 19 '05 #4
And just to show I can't ever make up my mind, I had an Avalon epiphany and
realized my control, which was merely rendering hierarchical data, is
logically just a TreeView with a very specialized visual tree (instead of
declaratively allowing <Setter Property="Template"/>, though, a WebControl
requires override Render(...))
End result? I'm subclassing TreeView such that I get to use the datasource
stuff MS already built into the infrastructure and let it take care of
repopulating the controls/wiring up events in the right time; I just worry
about defining a datasource the thing can use.
Nov 19 '05 #5

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

Similar topics

0
by: John Crowley | last post by:
I'm having an odd problem with viewstate and a dynamically created control inside a repeater template. Basically, I have a repeater setup like this in the aspx:
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am have facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
2
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
1
by: Marcus | last post by:
I have a problem maybe one of you could help me with. I've created a data entry screen with lots of dynamically-created client-side controls. I create HTML texboxes client-side by assigning a...
1
by: phil | last post by:
I decided to use AddOnPreRenderCompleteAsync to avoid holding on to a thread pool thread for too long. (I do some webserver I/O etc. during the page build). In the beginevent handler I fire up...
9
by: Chris | last post by:
I am dynamically adding a user control to each row in a gridview. The reason I am doing it dynamically is the user control is different depending on certain data in the gridview. The gridview...
4
by: mohaaron | last post by:
I can think of a lot of reasons why this might need to be done but as far as I can tell it's not possible. I've been looking for a way to add HtmlTableRows to a table using a button click for a...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...

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.