473,785 Members | 2,435 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AddOnPreRenderC ompleteAsync 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.AddOnPreRe nderCompleteAsy nc) that has events that can get fired?
Nov 19 '05 #1
4 3278
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******** *******@TK2MSFT NGP14.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.AddOnPreRe nderCompleteAsy nc) 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 programmaticall y process postback
events again during the prerender step. I thought I had something along
those lines with Page.RegisterRe quiresRaiseEven t, but I misunderstood the
method and wound up getting the last control created being reported as the
sender. Maybe something like Page.PersistFor PostBack(...), 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="Templ ate"/>, 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
2119
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
3024
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 web page dynamically. To do this, First I including a web page (MainPage.aspx) and I made form tag to Runat=Server. I included one table tag and also made this table Runat=Server side. Second I created three Web User Controls e.g....
1
2580
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 page dynamically. To do this, First I including a web page (MainPage.aspx) and I made form tag to Runat=Server. I included one table tag and also made this table Runat=Server side. Second I created three Web User Controls e.g. wucCustomerInfo.ascx,
2
2913
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 avoid the problem by avoiding the table control or resorting to databound controls that better manage state for me. I hope to understand how to solve the problem by using the Table web control and sticking to the approach of building the table at run...
1
3414
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 value to the td.innerHTML property. The UI is done, and I now want to post back the user's changes and update my business object in .NET. But when I postback, I can't see any of my dynamically created HTML controls in VB .NET. How do I make them...
1
1836
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 a new thread (not a thread pool thread, but rather System.Threading.Thread) and within that thread I do all of my page build. Eventually my endevent handler gets called and the page completes. It works perfectly except for one major problem: ...
9
7928
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 contains a placeholder and I add the control to it, the user control is a formview bound to an object datsource. This works great until I post back the page and the user control disappears. What am I doing wrong? Regards, Chris. Protected Sub...
4
2976
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 while and it seems it's not possible because the row that gets added with each click won't get recreated after a post back. After all the reading it seems that any dynamically created controls must be created in the Init event to be recreated after...
1
4913
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 set text boxes and labels inside the table rows. I then added a button. All of these are done through code. The problem that i am having is i can get the value from a text box with resides inside the first panel (out side of panel that is...
0
9645
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
9480
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
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8972
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
7499
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
6739
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
5381
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
4050
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.