dropdown list values and viewstate adding to page size, thus increasing page load time
I'm trying to fix a particular laboratory web application (written in ASP.NET). There is a page used for quick data entry, where the end-user uses a bar code scanner to input the data. Each time they scan a bar code on a sample (or test tube), it enters the actual data based on that bar code into a text field and tells the browser to tab to the next field. There are two bar codes they are scanning, and two text fields receiving data input. Many (in fact all) of the other fields may be already defaulted for a particular tray of samples, since that data doesn't need to chang开发者_高级运维e. This data entry is all about speed. I've fixed the form so that the tabbing (onblur event) uses an AJAX call to a WCF service. That's very quick. The problem is when they submit the form to save the test (based on the sample specimen). The form uses a full page postback. My goal is to eventually re-design the back-end architecture to eliminate the full page postback when saving the data and to use a WCF AJAX call for that as well. But for now, I'm just trying to figure out why the page is so slow. It is in fact the postback that causes the slowness. There are a few SQL queries slowing things down, I'm thinking the slowness is due to a dropdown containing 11,000 collection sites in it. The list loads each time the page loads. Is there a way I can speed up the page load time with that much data in this dropdown? Do I need to change that dropdown to being some type of auto-complete control with the top 5-10 matches (similar to how Google searches work) or is there a way to improve performance by keeping the dropdown there, but reducing the page load time? It's currently taking about 3 seconds to load the page. Does anyone know how to speed up the page load time?
=================
9/16/2011 update
Made a few changes. These are times based on when we submit the form without validation errors. Didn't implement caching yet. First I want to understand where the extra time came from?? Does anyone know?
2.8s (onload 3.55s) - original code
2.5s (onload 3.47s) - placing Not Page.IsPostback check around dropdown list 2.22s (onload: 2.79s) - removing 11,000+ collection sites in dropdown, and just putting one client name in there plus one for missing client option (at top)I'm not understanding how the Firebug Net tab is adding these times up. They don't add up to the total time. Why would that be? Where is the extra lag coming from?
356 ms
1 ms
1 ms
0 ms
2 ms
4 ms
5 ms
12 ms
4 ms
13 ms
24 ms
11 ms
12 ms
11 ms
13 ms
16 ms
11 ms
33 ms
20 ms
29 ms
12 ms
2 ms
2 ms
67 ms
9 ms
2 ms
2 ms
15 ms
2 ms
3 ms
16 ms
1 ms
1 ms
2 ms
1 ms
3 ms
6 ms
6 ms
5 ms
5 ms
1 ms
2 ms
=========
743 ms (total doesn't match ???)
Code after last change:
Public Overrides Sub BindNonViewstateLists()
'bind the client name drop down list, and keep track of the old value
'and whether or not it changed. Note that we will only use clients with
'status in a configurable list.
If (Not Page.IsPostBack) Then
'Dim clientDataTable As System.Data.DataTable = ApplicationContext.ClientManager.LoadAllForDDL(ApplicationContext.WorkflowConfig.WorkFlowDefinition("QuickDataEntry").GetSetting("ClientStatuses", "1"), "client.name", "client.identifyingnumber")
'ApplicationContext.DropDownListHelper.BindDDL(DDLClientName, clientDataTable, "Text", "Value", String.Empty)
Dim li As New ListItem("--- Client not available ---", CType(0, String))
DDLClientName.Items.Insert(0, li)
Dim li2 As New ListItem("Testing Client", CType(54321, String))
DDLClientName.Items.Insert(1, li2)
End If
...
At a guess the javascript (decompression / parsing / execution) is blocking the UI thread.
Try using dynaTrace AJAX edition to peek in a bit deeper than Firebug goes
If data from witch you load dropdown items does not change between postbacks. You can perform loading of data into dropdowno only when page is first time loaded.
Something like this:
if(!IsPostback)
{
// Load dropdown data
}
After that content of the dropdown will be saved in the ViewState, between postbacks. That will reduce time you need to show page after postback.
Also consider some kind of caching of data. I don't know how large is amount of data you load in the dropdown. May be that can be cached at application level?
精彩评论