What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

Rate It (2)

Last post 04-18-2007 12:51 PM by raja.krish. 46 replies.

Sort Posts:

  • What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-24-2006, 7:37 PM
    • Loading...
    • Eilon
    • Joined on 06-26-2002, 6:14 PM
    • Redmond, WA
    • Posts 716
    • AspNetTeam

    Intro:

    With the recent Microsoft ASP.NET AJAX Extensions release there has been a lot of feedback, both positive and negative, about the changes made to UpdatePanels. The feedback has ranged from “wow, finally validators work” all the way to “what the $%*@, my custom control doesn’t work!”

    The biggest change we made was related to script registration during async posts. We used to do some extremely hacky parsing work to detect the scripts rendered in a page and try to execute them on the client.

    Atlas CTPs (pre-beta):

    In the CTPs we had a special response writer that would parse the rendered contents of the page. It would look for specific items such as <script> tags, <input> tags, and a few other things. It worked really well for trivial scenarios such as a GridView with a textbox and a validator on the page. Unfortunately for us it turned out that most pages are significantly more complex.

    A classic example that didn’t work was a page that had an UpdatePanel with a wizard. Each step of the wizard contained a validator and a textbox. As you go through the wizard steps validators conceptually get removed and added to the page but nowhere was there any JavaScript code to remove the validator from the page. We would just keep adding more and more validators. Busted!

    Microsoft ASP.NET AJAX Extensions 1.0 beta:

    To overcome the problem of blindly reexecuting scripts that we parsed from the page we came up with an explicit registration model for scripts. This way the UpdatePanel can known exactly which scripts to execute, and when. The ScriptManager now has a set of static script registration methods. They are static so that they work on pages that don’t use partial rendering, including those that don’t even have a ScriptManager. You do, however, have to link to the Microsoft.Web.Extensions.dll to be able to call these.

    If you used to call:

                Page.ClientScript.RegisterClientScriptBlock(typeof(Foo), "key", "alert('hello'); ", true);

    You would now call:

          ScriptManager.RegisterClientScriptBlock(this, typeof(Foo), "key", "alert('hello');", true);

    If you look closely, there’s a new parameter for the method of type Control. This parameter is the precise reason why we needed the new set of registration methods. We use that parameter to detect whether the control registering the script is inside an UpdatePanel, and if so, whether that UpdatePanel is being refreshed during a given async post.

    We also require that controls implement dispose logic so that when an UpdatePanel is cleared out during an update the scripts inside it can tear down anything they need. This is done through a number of techniques, which I won’t go in too much depth here. The technique the validators use is to have a “dispose” expando on their rendered elements and the UpdatePanel client code will execute all the “dispose” expandos inside a panel that is getting cleared.

    Implications of having new registration APIs:

    One of the biggest implications of this is that existing controls that register scripts don’t work inside UpdatePanels. We are aware that this is a problem but we saw that it was necessary in order to make UpdatePanels work at all.

    Controls that shipped in ASP.NET 2.0:

    We have updated versions of the ASP.NET 2.0 validators that are tag-mapped to the old versions (this means that if you have an <asp:RequiredFieldValidator> tag it will use the updated one and not the old one. These updated validators use the new registration APIs.

    Other controls, such as WebParts, TreeView, and Menu were not updated to use the new registration APIs primarily due to time constraints. We felt that it was far less common to have these controls inside UpdatePanels compared to the validators. The TreeView control has built-in AJAX functionality anyway. In a future version of Atlas or ASP.NET we will have updated versions of these controls, however.

    3rd party controls:

    We have been working closely with custom control vendors to have them learn about the new APIs and many of them will be releasing updated versions of their controls that are compatible with UpdatePanel.

    Issues:

    We’ve still got a few things to work out for custom control vendors. And there are also some issues remaining for page developers. We love hearing this feedback from you since it makes a huge difference in how we build this awesome framework.

    I hope this helps explain some of our decisions in one place instead of scattering it in varied responses to several posts.

    Thanks,

    Eilon

    Blog: http://weblogs.asp.net/LeftSlipper/
  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-25-2006, 1:26 PM
    • Loading...
    • Eilon
    • Joined on 06-26-2002, 6:14 PM
    • Redmond, WA
    • Posts 716
    • AspNetTeam

    Giving this a bump. I'd love to here specific feedback on this subject.

    Thanks,

    Eilon

    Blog: http://weblogs.asp.net/LeftSlipper/
  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-25-2006, 1:41 PM
    • Loading...
    • pkellner
    • Joined on 11-12-2004, 10:42 AM
    • San Jose, California
    • Posts 3,370
    • Moderator
      TrustedFriends-MVPs

    reply to bump.

     

    Hi Eilon,

    Just trying to digest all this stuff. It's not that I'm not paying attention.  Still trying to figure out how to make the left and right side of my rounded corners from stopping disappearing.  :)

     

     

    Peter Kellner
    http://73rdstreet.com and blogging at
    http://PeterKellner.net
    MVP, ASP.NET
  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-25-2006, 2:44 PM
    Eilon:

    Controls that shipped in ASP.NET 2.0:

    We have updated versions of the ASP.NET 2.0 validators that are tag-mapped to the old versions (this means that if you have an <asp:RequiredFieldValidator> tag it will use the updated one and not the old one. These updated validators use the new registration APIs.

    Other controls, such as WebParts, TreeView, and Menu were not updated to use the new registration APIs primarily due to time constraints. We felt that it was far less common to have these controls inside UpdatePanels compared to the validators. The TreeView control has built-in AJAX functionality anyway. In a future version of Atlas or ASP.NET we will have updated versions of these controls, however.

     

    So does the part about 'WebParts' mean that things that worked in previous version of Atlas won't work now?  We had built some WebPart functionality that worked within an UpdatePanel and we're now concerned that this won't work once we upgrade to the Beta 1 release.

    We're already getting errors with references to the Microsoft.Web.UI.Controls.WebParts namespace.
     

    Michael De Lorenzo
    -------------------------------
    www.delorenzodesign.com ..:::.. delorenzodesign.blogspot.com
  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-25-2006, 10:40 PM
    • Loading...
    • Eilon
    • Joined on 06-26-2002, 6:14 PM
    • Redmond, WA
    • Posts 716
    • AspNetTeam

    Hi Michael,

    I believe we will still have WebParts support in the CTP (the Preview DLL), but probably not in the main Atlas DLL. I'm not sure exactly what we had in the beta but I think the RC will have that support as it was in the previous CTP.

    Thanks,

    Eilon

    Blog: http://weblogs.asp.net/LeftSlipper/
  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-26-2006, 4:42 AM
    • Loading...
    • flaxon
    • Joined on 07-18-2004, 9:01 AM
    • Posts 20

    Hello Eilon,

    can this be the reason (registering the script through the Manger) that no Extenders from the Toolkit are working on the first call inside WebParts that contain an UpdatePanel? After a post back (e.g. simply minimizing/restoring) the WebPart  they work.

    My control hierarchy:
    ... WebPart - UpdatePanel - (e.g.) HoverMenuExtender

    Thanks
    Flaxon

  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-26-2006, 8:17 AM
    • Loading...
    • nvivo
    • Joined on 04-14-2006, 9:01 PM
    • Posts 14

    Hi.

    I think it's a good change, since it simplifies the UpdatePanel work guessing what it needs to send, although we will need to code more and provide specific support for atlas.

    But it's a better model. I never experienced any problems like those you said, but until now, we used to create controls and it just worked with atlas, now we need to implement things, test and ensure it has been created to work with ajax.

    Now, I know it is still a beta, but do you think that the final MS ASP.NET Ajax will have many other breaking changes what happened from CTP to Beta?


    Thanks.

  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-26-2006, 8:17 PM
    • Loading...
    • Eilon
    • Joined on 06-26-2002, 6:14 PM
    • Redmond, WA
    • Posts 716
    • AspNetTeam

    IScriptControls (such as extenders) had many issues in the beta. We are planning on having that fixed for the next release.

    The amount of changes from here on out will be a lot more limited. Of course there will be some breaking changes but only where we felt it was really necessary. The main cause of changes between the CTP and the beta was design changes, and those in turn create a lot of other changes. In subsequent releases we don't plan on redesigning anything, but things such as method names, namespaces, and slight behavior changes should be expected.

    Thanks,

    Eilon

    Blog: http://weblogs.asp.net/LeftSlipper/
  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-27-2006, 1:37 AM
    • Loading...
    • JRumerman
    • Joined on 03-01-2006, 6:26 PM
    • San Diego, CA
    • Posts 140

    Is there going to be a certification test for 3rd party custom control vendors so that we can be assured that they place nice with Atlas? Something like the Windows Driver Verification stuff? It's really important that not only does a vendor claim that they are Atlas compliant, but Microsoft says, "yes, they are Atlas compliant. Go ahead and use it."

     

    Some seriously awesome stuff went into the Beta release. Sweet.  

     

    Thx, Joel

  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-29-2006, 1:02 AM
    • Loading...
    • sptzone
    • Joined on 09-26-2006, 9:31 AM
    • Posts 5

    hi,Eilon:

           As you said, the mechanism is different now.

          So can you tell me how to use the UpdatePanel now if the UpdatePanel can work in another mechanism.

          Are there some links?

          Thanks!!!

  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-29-2006, 6:57 PM
    • Loading...
    • Eilon
    • Joined on 06-26-2002, 6:14 PM
    • Redmond, WA
    • Posts 716
    • AspNetTeam

    Here's a new article on how to write controls that are compatible with UpdatePanel without having to link to the Microsoft ASP.NET AJAX assembly:

    http://forums.asp.net/thread/1445844.aspx 

    Thanks,

    Eilon

    Blog: http://weblogs.asp.net/LeftSlipper/
  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-30-2006, 7:34 PM
    • Loading...
    • mharder
    • Joined on 11-22-2002, 12:03 PM
    • Redmond, WA
    • Posts 917
    • AspNetTeam
      Moderator

    Here's a summary of WebParts support in Atlas 1.0.  There are three different WebParts features:

    1. Cross-browser drag and drop.
    2. Modify WebParts page (drag and drop, minimize, restore, add, close, etc.) without postback.
    3. Update contents of WebPart without postback.

    Cross-browser drag and drop is enabled by using the WebParts controls in the AJAX “ValueAdd” CTP.  This was working in July CTP, and should still be working in the current release.  This will continue to work in the AJAX "ValueAdd" CTP.

    #2 is implemented by wrapping the WebPartManager and WebPartZones in an UpdatePanel.  This was partially working in the July CTP.  It is not supported in Atlas 1.0, in either the AJAX “Core” or the AJAX “ValueAdd” CTP.  It should be supported in Orcas.

    #3 is implemented by placing an UpdatePanel inside a WebPart.  This was also partially working in the July CTP.  This is fully supported in the AJAX 1.0 “Core”.  It should work with either the ASP.NET 2.0 WebParts controls, or the AJAX “ValueAdd” CTP versions of the WebParts controls.

    Hope this helps,

    -Mike

    http://blogs.msdn.com/mharder

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-30-2006, 11:53 PM
    • Loading...
    • EssaiMeilleur
    • Joined on 09-25-2006, 9:18 PM
    • Tampa Bay, FL
    • Posts 60

    Nice work Eilon, the changes sound great and I look forward to implementing them. Now you just need to add the ability to customize how the UpdatePanel is rendered. Being limited to either a div or span is pretty crummy. I've built upon the existing UpdatePanel to add this functionality for the time being, but it would be awesome if it came standard.

    I look forward to hearing all new developments. 

  • Re: What's up with UpdatePanels and how come nothing works? Or: A brief explanation of how UpdatePanel works by the guy who wrote the feature. (Long!)

    10-31-2006, 4:32 AM