Making the most of out the AjaxControlToolkit’s ModalPopupExtender Part 8

This is the second to last post in this series, and basically this is just going to be some trace.axd output comparing a WebMethod populated Modal Dialog with an Update Panel generated dialog. Instead of the really basic UI I've been using to prototype some of this code, I'm going to use a simple Grid/Detail setup using an asp:repeater combined with the modal popup to view the details. I'm going to use a Customer/Location Domain/DAL setup that I've got floating around (see here for what I'm talking about). I'm not going to include code in this post, there's too much to be meaningful, instead I've decided to make my next set of blog posts about creating a canned set of Domain objects, with some nice static data seeding helpers.

I'd still like to emphasize that this is not a production level code to production level code comparison, rather just a stake in the ground to get an idea of the cost of doing things the long way vs. the short way. The thing I've realized is that the easier that the .Net framework makes things, the harder it is to get something to work just the way you need it to. Almost without exception every portion of chocolaty code goodness that I sample from the .Net factory suffers from the problem of trying to be all things to all people. 8 out of 10 times this might just be what's needed, but the really fun, challenging projects just aren't able to take advantage of the sugar that's already made. This is not surprising, nor in anyway a shortcoming of the .Net framework, just a reminder that there will always be a need for skilled coders who like looking over the side of the bridge.

Nuts and bolts:

This sample project puts the WebMethod based Modal approximately 2-3 times faster than the UpdatePanel. This is completely arbitrary of course, because the only real determining factor is the amount of time it takes to render the entire page vs. the actual content required.

Here's a screen shot of the app with the first of two modal dialogs showing. Basically it's a list of customers, that opens a modal with a list of Locations, that allows you to select a single location to get it's details. There are 2 WebMethods GetLocations, and GetLocationDetails, and for the UpdatePanel version, there's a ControlLoader that knows how to select the proper content. Again this app is very simple, and the page render times would be more than adequate for either approach on any production page I've seen, but this again is about understanding what we are working with.

 

Here's the timings from the WebMethod approach:

Category 

Message 

From First(s)

From Last(s) 

WebMethod 

In GetLocations 

  

AjaxControlRenderer 

Create Page 

2.15111138426811E-05 

0.000022 

AjaxControlRenderer 

Create Header 

4.00190527008321E-05 

0.000019 

AjaxControlRenderer 

Create Form 

9.88952506533652E-05 

0.000059 

AjaxControlRenderer

Create ScriptManager 

0.000146317478897458 

0.000047 

AjaxControlRenderer 

Load Control: LocationsList.ascx 

0.00019080637343573 

0.000044 

AjaxControlRenderer 

Add Header 

0.000250101619060523 

0.000059 

AjaxControlRenderer 

Add Form 

0.000276361939855484 

0.000026

AjaxControlRenderer 

Add ScriptManager 

0.000292215910122655 

0.000016 

AjaxControlRenderer 

Add Control: LocationsList.ascx 

0.000308000039111116 

0.000016 

AjaxControlRenderer 

Bind Control: LocationsList.ascx 

0.000323225437869897 

0.000015 

AjaxControlRenderer

Render Page 

0.000438463547741403 

0.000115 

AjaxControlRenderer 

Parse Output 

0.00968670599196267 

0.009248 

AjaxControlRenderer 

Render Complete 

0.00976849012933208 

0.000082 

 

Here's the UpdatePanel Timings:

Category

Message

From First(s)

From Last(s)

aspx.page

Begin PreInit

  

aspx.page

End PreInit

2.09523836130011E-05

0.000021

aspx.page

Begin Init

3.72254015524319E-05

0.000016

aspx.page

End Init

8.33206455010343E-05

0.000046

aspx.page

Begin InitComplete

0.000101130171572085

0.000018

aspx.page

End InitComplete

0.000116844459281836

0.000016

aspx.page

Begin LoadState

0.000129834937121897

0.000013

aspx.page

End LoadState

0.000349765123779698

0.000220

aspx.page

Begin ProcessPostData

0.000370158777163019

0.000020

aspx.page

End ProcessPostData

0.000585549280704671

0.000215

aspx.page

Begin PreLoad

0.000603079441660881

0.000018

aspx.page

End PreLoad

0.000618793729370632

0.000016

aspx.page

Begin Load

0.000632901667670053

0.000014

aspx.page

End Load

0.0010423810847468

0.000409

aspx.page

Begin ProcessPostData Second Try

0.00106026045209657

0.000018

aspx.page

End ProcessPostData Second Try

0.00108638109033411

0.000026

aspx.page

Begin Raise ChangedEvents

0.0011009779175845

0.000015

aspx.page

End Raise ChangedEvents

0.00111948585644265

0.000019

aspx.page

Begin Raise PostBackEvent

0.0011331049057911

0.000014

aspx.page

End Raise PostBackEvent

0.00236147331574264

0.001228

aspx.page

Begin LoadComplete

0.00238382252492984

0.000022

aspx.page

End LoadComplete

0.00239876855857379

0.000015

aspx.page

Begin PreRender

0.00241231776664353

0.000014

aspx.page

End PreRender

0.0144583319947088

0.012046

aspx.page

Begin PreRenderComplete

0.014490808189309

0.000032

aspx.page

End PreRenderComplete

0.0146703002755937

0.000179

aspx.page

Begin SaveState

0.0186679452276756

0.003998

aspx.page

End SaveState

0.0188630119191126

0.000195

aspx.page

Begin SaveStateComplete

0.0188810309690198

0.000018

aspx.page

End SaveStateComplete

0.0188945801770895

0.000014

aspx.page

Begin Render

0.0189075008136509

0.000013

aspx.page

End Render

0.0239341173249673

0.005027

 

Really the difference in a typical page might be not much worse than this, on the other hand a page that's rich with content might present an entirely different story with several hundred milliseconds being burned on unneeded tasks. In reality though, some good design work could easily mitigate the overhead of the full page render associated with an update panel. Yes this would require target specific coding, but at least in my example here, so does the WebMethod based approach. The number one thing I that's a true benefit of using WebMethods it's a thorough understanding of the process, the what, why how of making a responsive web base application, but more on that on Part 9 of this series.

Print | posted on Saturday, October 20, 2007 11:16 PM
Comments have been closed on this topic.