Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Disposing dynamically created behaviors(extenders) within an update panel

Disposing dynamically created behaviors(extenders) within an update panel

Scheduled Pinned Locked Moved ASP.NET
questiontoolshelptutorialannouncement
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ali Al Omairi Abu AlHassan
    wrote on last edited by
    #1

    Guys; As you might know, all extenders are created by calling the function $create() just on the event Sys.Application.init. And disposed by calling the function $find('_componentId_').dispose() ether on the event Sys.Application.unload (closing the page) or by updating the containing UpdatePanel. My question is; in case we create the behavior(the extender) dynamically by calling the function $create() through the client script, then how to register disposing it when the UpdatePanel is updated?

    Help people,so poeple can help you.

    A 1 Reply Last reply
    0
    • A Ali Al Omairi Abu AlHassan

      Guys; As you might know, all extenders are created by calling the function $create() just on the event Sys.Application.init. And disposed by calling the function $find('_componentId_').dispose() ether on the event Sys.Application.unload (closing the page) or by updating the containing UpdatePanel. My question is; in case we create the behavior(the extender) dynamically by calling the function $create() through the client script, then how to register disposing it when the UpdatePanel is updated?

      Help people,so poeple can help you.

      A Offline
      A Offline
      Ali Al Omairi Abu AlHassan
      wrote on last edited by
      #2

      We can achieve that by by calling the function Sys.WebForms.PageRequestManager._registerDisposeScript(); which registers the the component on updating the parent UpdatePanel just like the code below:

      Sys.WebForms.PageRequestManager.getInstance()._registerDisposeScript('parentupdatepanelid', 'var component = $find("componentid"); if (component != null)component.dispose()';

      The disposing script(the second argument) is executed by the function Sys.WebForms.PageRequestManager._updatePanel which is called when an UpdatePanel is updated. (the code below)

      function Sys$WebForms$PageRequestManager$_updatePanel(updatePanelElement, rendering) {
      for (var updatePanelID in this._scriptDisposes) {
      if (this._elementContains(updatePanelElement, document.getElementById(updatePanelID))) {
      var disposeScripts = this._scriptDisposes[updatePanelID];
      for (var i = 0, l = disposeScripts.length; i < l; i++) {
      eval(disposeScripts[i]);
      }
      delete this._scriptDisposes[updatePanelID];
      }
      }
      this._destroyTree(updatePanelElement);
      updatePanelElement.innerHTML = rendering;
      }

      I added the if statement to the disposing script because the component can be disposed before the UpdatePanel is updated so the function $find() would return a null and we would have a Null Reference Exception. So what about the behaviors that is created after ExtenderControls on the Page that have disposing scripts of '$find("_componentid_").dispose();'?

      Help people,so poeple can help you.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups