ASP.NET - Asynchronously load UpdatePanels when page loads - c#

I have a page which uses WebParts to display differents sections that the users can configurate, so in this page can be lots of them, each of them calling to our API to retrieve DB data.
Right now, these sections are loading synchronously, and the page may need too much time to load, so I've wrapped each section in an UpdatePanel and tried to load them asynchronously. I use an asp:Timer to do so. Now, the page renders and then the UpdatePanels start to load when the timer ticks, but the problem is that these UpdatePanels load synchronously (one after the other). So, if the first UpdatePanel needs 10 seconds to load, the second one will start to load just after.
What can I do to load them all at once asynchronously?
Thanks in advance

asp.net webforms is not designed to work asynchronously, so as far as i know you cannot tweaks the updatepanels to do that.
I suppose you could somehow overload the updatepanel scripts, but it would really add too much complexity.
The easiest thing you could do is to not load all the webparts in the same page.

Related

Webbrowser control sometimes doesn't fully load a page, but document_completed event is fired

I have a scraper that scrapes data from three kinds of websites.
One of those websites (Facebook) have multiple page formats that needs to be scraped.
While two websites work fine, one particular Facebook page layout refuses to work or work very strangely. (for other Facebook page layouts I haven't noticed this behavior)
I am reading each link from a file and load into webbrowser control, I wait until each page fully loads (using AutoResetEvent) and then after it loads, I send pages html to other class from the webbrowser_Document_Completed event to do the scraping.
The problem here is that sometimes page is not fully loaded and sometimes it fully loads.
In both cases webcontrol_Document_Completed is fired.
When the page fully loads, it works just fine.
I debugged and indeed, page is not fully loaded and data is missing.
It can pass 4-5 times in a row to fully load the page and then suddenly stops. (random pattern)
I don't know anymore where to look for the culprit.
I thought that my code is not ok so I created new test project that just loads that page and same problem occurs.
So maybe the page is the problem because I also saw that when it doesn't work, needed data is commented.
Maybe some scrape protection...
Page in question is: https://www.facebook.com/pages/Childrens-Dental-Care/76095547112?v=info&viewas=0 and needs to scrape right side of the page where is Joined Facebook, Hours and Parking.
It's //td[#class='data'] element that I need.
If you have any idea that might point to solving this issue...
Thank you!

What is happening between PreRender and Unload

I have an ASP.NET Webforms master page which is taking 3.5 minutes to render, and I can't figure out why.
I added logging, and it goes through Load and PreRender super fast, but after that, takes 3.5 minutes to get to Unload.
The page being rendered is pretty small, about 80k, and the viewstate is about 10k (guessing).
Figured it out. In my case, Umbraco was responsible for generating the 'Page' as all I had was a MasterPage containing controls. One of these controls had a datasource which was making web requests for each row it got back from the database. These requests were failing silently and timing out.

Is there an event called after a gridview is completely finished?

Or a way to detect it is finsihed rendering?
Actually almost exactly this question
Gridview, is there an event, how would I determine that it has finished being rendered?
but he does not state exactly how he detected that everything had been drawn/resized.
EDIT: (Adding my comment from below to specify what i am trying to do)
I am trying to create a work around for static header for a gridview by basically dynamically adding another gridview above the one that actually has the data in it. I resorted to this after trying about 12 different suggestions/solutions with no real luck. What i have works pretty well except that the new header is rendered before the one with the data in it completes its re-sizing, I realize what i am trying might not even work since it might require another postback to re-render the new one after i find the sizes of the column headers but thought i might get around that with an update panel.
I realize this might not be the most elegant solution but honestly have yet to find any solutions to this problem that come even close to elegant or have even worked correctly with current browsers.
It renders at the client so the server doesn't know what is happening there.
You are probably looking for the DataBound event.
Otherwise, at the client, you can determine when the page has finished loading (the jquery ready function) and then call back to the server. But I can't imagine anything useful you could do. If you send more data to the client and it renders again, you could have an infinite loop.
Everything in an ASP.Net webpage is rendered at the same consecutively at the same stage of the lifecycle (see http://msdn.microsoft.com/en-us/library/ms178472.aspx), so the Gridview will be rendered between Gridview_PreRenderComplete and Gridview_Unload.
You page PreRender will fire, then the control PreRender, then the page will call the Gridview Render method (there is no event for this) then the control Unload will fire and then the page Unload will fire.
Other posters to this question are referring to the client side rendering whereas I am referring to the server side rendering process. Which is it that you are actually after and why please?

Looping through aspx pages

For a tournament application, i have to output group standings and a knockout schedule. They have to alternate on one big LED TV. I managed to do that using an IFrame that spanned 100% of the page and using javascript to set the iframe source to another aspx page every 10 seconds.
This works but i creates an enormous memory leak. each time a page is loaded in the iframe, the Internet Explorer process grows with about 6mb. this results in a IE process of 1,5Gb and a crash of the window after about 1 hour.
Is there a better way to create something similar? do the cycling all in codebehind?
Thanx,
Cypress
Why the need for the iframe? You could just have the page reload every 10secs with an onload script.
A more clever approach, might be to use AJAX to download only the data you need to display & update the page with that. You could then take a stage further & use something like SignalR to only update the screen when the data changes.

wp7 preload silverlight page

I have settings page in my wp7 application. I loads for quite long time first time since I add looping selector. I there any correct way to precreate\preload this page earlier;
It's not possible to preload the page but there are lots of other things that could be done to improve the load time/performance:
Adjusting when in the page lifecycle the contents are loaded
What's loaded
The order items are loaded
The complexity of what and how things are displayed
Preload the data/model
and many more...

Categories

Resources