CollapsiblePanel : firing server side code upon Expand

Last post 07-02-2009 11:01 AM by ibussieres. 3 replies.

Sort Posts:

  • CollapsiblePanel : firing server side code upon Expand

    06-30-2009, 4:05 PM
    • Member
      3 point Member
    • ibussieres
    • Member since 06-02-2009, 8:49 AM
    • Posts 16

    Hello,

    I am working on a fairly complex page that causes a lot of traffic on the server. Me and my teammates have decided to preload certain sections of the page and only load the other sections upon user actions (please note that every section is a collapsible panel). To do so, every section has been encapsulated in the form of a UserControl and is dynamically loaded through the Page_Load event.

    Now, I would like to only load these controls in my panels that are expaned by default when I load my page and load all other controls when a user expands the panel in which the given control is nested. I would then display a loading circle for longer database accesses, if there are any. Of course, this would all be done in server side code.

    I noticed that there are no OnExpand or OnCollapse events on the CollapsiblePanelExtender and my teammates and I would prefer using a solution that would not imply modifying the Toolkit source code. Are there any suggestions on how I can fire events upon expanding an ASP.NET AJAX CollapsiblePanel?

    I've Googled around a fair amount but I can't seem to find a suitable solution.

    Note : I am using the latest version of the Toolkit, Visual Studio 2008, C# Code behind and the 3.5 .NET Framework.

    As usual, any suggestions, advice or interesting links are more than welcome.

    Regards,

    Ian Bussières.

  • Re: CollapsiblePanel : firing server side code upon Expand

    06-30-2009, 7:39 PM
    • Participant
      1,483 point Participant
    • Ambran
    • Member since 03-18-2009, 2:23 PM
    • Denmark
    • Posts 285

    Hi Ian

    This is only possible client-side by adding JavaScript handlers to the CollapsiblePanel extender.

    Observe these threads to see how:

    http://forums.asp.net/t/1150124.aspx

    http://stackoverflow.com/questions/917010/collapsiblepanelextender-click-event

    Amit

    If this post was of any help to you, Mark it as Answer for the benefit of others, Thanks.

    Spread Firefox Firebug - Web Development Evolved
  • Re: CollapsiblePanel : firing server side code upon Expand

    07-02-2009, 10:36 AM
    • Member
      3 point Member
    • ibussieres
    • Member since 06-02-2009, 8:49 AM
    • Posts 16

    Thanks for the useful articles, I've concentrated my efforts on the second one.

    I am not exactly what one would call a javascript expert, though. In the example given, it is said that I should hook onto the Collapsible Panel client side events with the following code.

     var extender = $find('cpeDescription.ClientID');
    extender.add_collapsed( function() { alert('collapsed'); });
    extender.add_expanded( function() { alert('expanded'); });

    This brings up a problem where 'extender' always returns null. I've also tried regestering the function through ClientScriptManager.RegisterStartupScript() on server side, but that failed in both Page_Load and Page_LoadComplete lifecycle events.

    Strangely enough, in the rendered markup, the ClientID seems to have been successfully found : 

    ctl00_ctl00_Main_PackagePlaceHolder_cpeDescription

    So that's where I stand, any suggestions from here? I'm still searching around for similar problems, not quite getting what I need.


     

     

  • Re: CollapsiblePanel : firing server side code upon Expand

    07-02-2009, 11:01 AM
    Answer
    • Member
      3 point Member
    • ibussieres
    • Member since 06-02-2009, 8:49 AM
    • Posts 16

     I have fixed my problem using a behavior Id and firing my hookups in the pageLoad javascript function.

Page 1 of 1 (4 items)