Known Issue & Workaround: Extenders no longer work in templated controls

Last post 07-08-2008 6:09 PM by ChhayaBhat. 30 replies.

Sort Posts:

  • Known Issue & Workaround: Extenders no longer work in templated controls

    10-25-2006, 7:40 PM
    Locked
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam

    Summary: 

    Due to a known issue with ASP.NET AJAX Beta 1, you may find that Extender controls no longer work with templated controls such as GridView or FormView.  This issue will be addressed in the next release of ASP.NET AJAX.

    Background:

    The ScriptManager component on your ASPX page is responsible for rendering out the client script (JavaScript) that creates the client side components.  The ScriptManager walks the list of components that need these hookups during it's PreRender phase of the page lifecycle.  Unfortunately, templated controls often create their inner control heirarchies during PreRender as well.  Therefore, since the ScriptManager appears earlier in the page than the templated control, the extenders have not been created yet, and the hookups don't happen.

    Workaround:

    Fortuantely, for the common case, there is a simple workaround.  You simply need to force control generation earlier in the page lifecycle.  The simplest way to do this is to call DataBind method or Controls property from the Page_Load. 

    protected void Page_Load(object sender, EventArgs e)

    {

         GridView1.DataBind(); // for databound controls

        object o = Login1.Controls; // for templated controls

    }

    Caveat:

    This doesn't work for templated controls that make changes to their tree, such as a GridView with an EditItemTemplate in it.  If you have that scenario, unfortunately, you'll need to wait for the next release of ASP.NET AJAX Beta 1 to enable it.

     

    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-25-2006, 7:51 PM
    • All-Star
      33,841 point All-Star
    • vcsjones
    • Member since 04-18-2006, 8:53 PM
    • Falls Church, VA
    • Posts 4,319
    • Moderator
      TrustedFriends-MVPs
    Thank explains a lot. Thanks for the information.
    Cheers,
           Kevin Jones


  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-26-2006, 12:10 AM
    • Contributor
      4,482 point Contributor
    • jodywbcb
    • Member since 03-12-2003, 3:52 PM
    • West Seattle,WA
    • Posts 985

    So question... and this refers to this blog post  my databound events for the Gridview - and I load it only once as once loaded I assume the Scriptmanager has it and everything is all and well... your example indicates that the gridview must be loaded on each page_load which has no logic to determine if it is a postback.  Most devs interpret a postback as being that the client side already has whats it needs..Which is one of the problems I have with the simple examples provided for the kit and why I end up blogging about my real world examples.  And granted I think my scenario is complicated by the inclusion of the ModalPopup - but I am at a loss why the correlation of the two results in scripts feed down and registered with the initialization of the page invoked and registered by the databound event are lost....

     

    Wish I had more explicit comments to add but I am yet to get debugging to work properly due to the fact the website itself is nothing but skins and logic is compiled seperately... so I have no ability to attach to anything with two totally seperate projects...

     

     

    -- jody
    My Blogs on .Net 2.0 and Ajax
    http://csk.wbcb.com
    http://ArtbyJody.com
  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-26-2006, 3:10 AM
    • Member
      15 point Member
    • cnupy
    • Member since 10-26-2006, 6:53 AM
    • Posts 5

     

    Approximately when we should expect fix for this issue? I've spent two days of changing our stuff from latest CTP to Beta 1 just to realize that it won't work :(

    Thanks

  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-26-2006, 10:52 AM
    • Member
      5 point Member
    • mazrad
    • Member since 10-26-2006, 2:24 PM
    • Posts 1

    I have this problem as well.  This is the crappy workaround I am currently using:

    Try creating a function like this

    function fixAC()
    {
    try {
          Sys.Application.add_init(function() {
          $create(Sys.Preview.UI.AutoCompleteBehavior, {"minimumPrefixLength":1,"serviceMethod":"theMethod","serviceURL":"theService.asmx"}, null, null, $get('theControlID'));
          });
        }
    catch (e)
        {}
    }
    

     

    Call it from the onload.

    This manually hooks up the extender. 

  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-26-2006, 12:21 PM
    • Member
      15 point Member
    • dern
    • Member since 10-24-2006, 2:27 PM
    • Posts 3
    sburke_msft:

    Caveat:

    This doesn't work for templated controls that make changes to their tree, such as a GridView with an EditItemTemplate in it.  If you have that scenario, unfortunately, you'll need to wait for the next release of ASP.NET AJAX Beta 1 to enable it.

    As a newb I'm not sure if my situation is caught by your caveat... could you confirm this for me?

    I have a datalist which contains a collapsible panel and I can work around the problem by calling databind on the datalist. This results in the collapsible panels working correctly. However within each datalist iteration I have another nested datalist. This nested datalist generates another collapsible panel for each iteration. Basically I have a list of rulesets, each of which are expandable, and each rule set is comprised of rules, each of which are expandable.

    Using this code...

      protected void Page_Load(object sender, EventArgs e)
      {
        this.RulesetDataList.DataBind();
      }

    ...the outer datalist is bound and the outer layer of the collapsible panels work ok but the inner ones do not. So I added this code...

      protected void RulesetDataList_ItemDataBound(object sender, DataListItemEventArgs e)
      {
        if((e.Item.ItemType == ListItemType.AlternatingItem) || (e.Item.ItemType == ListItemType.Item))
        {
          DataList RuleDataList = (DataList)e.Item.FindControl("RuleDataList");
          if(RuleDataList != null)
          {
            RuleDataList.DataBind();
          }
        }
      }

      ...to bind the inner datalists and thereby enable the inner collapsible panels. However, while the code that does the databinding operation on the inner data lists works fine (the control is found and the databind method runs without blowing up) the end result is that the following error message is generated...

    "Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and Behaviors. Parameter name: element"

     ...on this line...

    Sys.Application.add_init(function() {
        $create(AjaxControlToolkit.CollaspablePanelBehavior, {"ClientStateFieldID":"rule_CollapsiblePanelExtender_ClientState","CollapseControlID":"rule_Header","Collapsed":true,"CollapsedImage":"images/expand.jpg","ExpandControlID":"rule_Header","ExpandedImage":"images/collapse.jpg","id":"rule_CollapsiblePanelExtender","ImageControlID":"rule_ToggleImage","SuppressPostBack":true}, null, null, $get('rule_Content'));
    });
    

     Does that give enough information to determine if I'm caught by your caveat or not?

     Thanks,

     Mark

     

  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-26-2006, 2:47 PM
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam

    I don't think that's the same issue.  It's looking for an element called rule_content, which isn't on the page for some reason.  Look closer at what it's trying to hook up to and hopefully that will give some clues.

     With some luck, the next AJAX release will be within the next few weeks.

    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-27-2006, 12:25 AM
    • Member
      233 point Member
    • MatthewHill
    • Member since 02-13-2006, 8:19 PM
    • New Zealand
    • Posts 109

    I figured out the Datasource fix but don't understand how the templated one is meant to be implimented:

    How do I use:    object o = Login1.Controls; // for templated controls

    Thanks

    Matthew



    Regards

    Matthew
  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-27-2006, 5:34 AM
    • Member
      25 point Member
    • sptzone
    • Member since 09-26-2006, 9:31 AM
    • Posts 5

    when will be the next release coming?

    because we use the hovermenu in our project and we can't add "delete" and "load" function.

     

    thanks.

    hope for the next release!!!

  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-27-2006, 7:09 AM
    • Participant
      1,526 point Participant
    • James_2JS
    • Member since 02-13-2006, 3:21 PM
    • Posts 335

    This is a huge pain for me too!!

    I use NumericUpDown extenders in the EditItemTemplate of a GridView... and they simply don't work!!

    There is absolutely no way that I can use AJAX Beta 1... it's FATALLY flawed!!

  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-27-2006, 8:38 AM
    • Member
      42 point Member
    • marvin966
    • Member since 10-20-2006, 6:25 PM
    • Quebec
    • Posts 11
    James_2JS:

    This is a huge pain for me too!!

    I use NumericUpDown extenders in the EditItemTemplate of a GridView... and they simply don't work!!

    There is absolutely no way that I can use AJAX Beta 1... it's FATALLY flawed!!

     

    Same here, I am using ConfirmButton Extender inside template of a gridview, and since most of our pages are using gridviews with extenders in templates, it is a major issue in our case.

    Hopefully the next release will be out soon... 

  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-27-2006, 5:05 PM
    • Member
      233 point Member
    • MatthewHill
    • Member since 02-13-2006, 8:19 PM
    • New Zealand
    • Posts 109

    I have Extenders in my FormView edit and insert templates and so far this has worked really well in my project:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Not IsPostBack Then

    FormView1.DataBind()

    End If

    End Sub



    Regards

    Matthew
  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-30-2006, 12:58 PM
    • Member
      100 point Member
    • flaxon
    • Member since 07-18-2004, 9:01 AM
    • Posts 20

    This seems to be the reason because the Extenders do not work in WebParts! WebParts also rendered in the PreRender event.

    Will the next release fix this issue, too?

  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-30-2006, 10:28 PM
    • Member
      247 point Member
    • Yabadabadoo
    • Member since 07-18-2005, 4:49 PM
    • Posts 83

    It's not just with tempalted controls.  The extenders, namely, the PopupControlExtender, does not work in my custom webcontrols either (whose innerproperties are panels rather than templates). 

    The workaround which involves calling the Controls collection is a little misleading.  The reason why it works is because the Controls accessor is generally overridden in Microsoft controls to also call the function EnsureChildControls (look at the source code for the AccordionPane).  I exposed a property in my custom webcontrol that causes EnsureChildControls to be called and I  called it in Page_Load as suggested, and voila, the PopupControlExtender works. 

    Yes it's a bit Mickey-Mouse but it's a band-aid for now.  Hope this helps anyone else who is having a problem with their custom webcontrols. 

  • Re: Known Issue & Workaround: Extenders no longer work in templated controls

    10-31-2006, 2:48 AM
    • Contributor
      4,482 point Contributor
    • jodywbcb
    • Member since 03-12-2003, 3:52 PM
    • West Seattle,WA
    • Posts 985

    Yabadabadoo:... 

     

    Thanks for posting that...I started comparing the accordian control to the modal popup....  and while I don't do the Page_Load Trick...  In another post

    describes the 'double - postback' issue I was having... so I modified the t\AjaxControlToolkit\ModalPopup\ModalPopupExtender.cs to do the EnsureChildControls() on all the initial [ExtenderControlProperty()] I could find.

    Not only did it speed up the.Show() of the modal by a huge amount(it was taking a good 10 seconds for the modal to popup now less than 1 when first initialized)... BUT - I got rid of the double post scenario I was having at least in the scenario I posted.  Now I get two on the close of the MOodal but the first one is a zero byte and the second is just what is needed or at least expected all things considered....

    Thanks for posting that as I had been tearing it apart trying to figure out the issues thinking I could become a javascript expert in a weekend - and that just won't happen... but at least this resolved portions of my issue...  still can't figure out most of the other issues I have brought up and no one has responded to... but none the less... nice discovery... 

     

     

    -- jody
    My Blogs on .Net 2.0 and Ajax
    http://csk.wbcb.com
    http://ArtbyJody.com
Page 1 of 3 (31 items) 1 2 3 Next >