in
Forums
Blogs
DevExpress.com
Client Center
Support Center
DevExpress Channel

multiple controls and multple ASPxCallbackPanel

Last post 9/28/2009 3:13 AM by Quentin. 3 replies.
Sort Posts: Previous Next
  • 6/26/2009 4:55 PM

    multiple controls and multple ASPxCallbackPanel

     Hi,

    1. I have a Custom User Control that looks like this:

    <dxcp:ASPxCallbackPanel runat="server" ID="cbSecondaryDimControl" ClientInstanceName="cbSecondaryDimControl"
        CssClass="cbSecondaryDimControl"
        oncallback="cbSecondaryDimControl_Callback" >
        <PanelCollection>
        <dxp:PanelContent>
       
            <table id="tableSecDim" runat="server" border="0" cellspacing="0" cellpadding="0" class="tableSecDim">
                <tr>
                    <td id="cell1" runat="server" class="secondaryDimControlLeft"></td>
                    <td id="cell2" runat="server" class="secondaryDimControlFill secondaryDimControlSpacer"></td>
                    <td id="cell3" runat="server" class="secondaryDimControlFill">
                       <dxe:ASPxLabel ID="secondaryDimensionLabel" runat="server">
                        <ClientSideEvents
                         Click="function (s,e) { SecDimControl_Click(s,e); }"
                         />
                       </dxe:ASPxLabel>
                    </td>
                    <td id="cell4" runat="server" class="secondaryDimControlFill secondaryDimControlSpacer"></td>
                    <td id="cell5" runat="server" class="secondaryDimControlFill secondaryDimControlButton">
                        <dxe:ASPxImage ID="secondaryDimControlButton" runat="server" ImageAlign="Middle"
                            ImageUrl="~/App_Themes/Aptitrak/Images/secondaryValueExpandButtonUp.png"
                            CssClass="secondaryDimControlButton">
                        </dxe:ASPxImage>
                    </td>
                    <td id="cell6" runat="server" class="secondaryDimControlRight"></td>
                </tr>
            </table>
           
        </dxp:PanelContent>
        </PanelCollection>

    2. I can have one to 'n' of these on an asp.net web page contained within other controls.

    3. I need to know when the label control (ID="secondaryDimControlButton") is clicked, from which parent control it was clicked from and perfrom a callback so some server-side updates can be made to that control.

    4. On the click I call the following function client-side function:

     function SecDimControl_Click(s,e)
    {
        var params = CallbackParamsToString({ "Action": "SecDimClick" });
        cbSecondaryDimControl.PerformCallback(params);
    }

    s.name = "ctl00_MainTab_PagePane1_pagesPanel_pagePanelYears_secDim2006_cbSecondaryDimControl_secondaryDimensionLabel"

    s.uniqueID = "ctl00$MainTab$PagePane1$pagesPanel$pagePanelYears$secDim2006$cbSecondaryDimControl$secondaryDimensionLabel"

    THOUGH the client side also shows this:

    this.name="ctl00_MainTab_PagePane1_pagesPanel_pagePanelMeasures_secDimDataPart_cbSecondaryDimControl"

    this.uniqueID="ctl00$MainTab$PagePane1$pagesPanel$pagePanelMeasures$secDimDataPart$cbSecondaryDimControl"

    5. I want to perform the callback for the control returned in the 's' parameter, not the control specified by the 'this'
    But when I call cbSecondaryDimControl.PerformCallback(params);  and use the 'this' property on the server-side it is not for the correct control.

    Is there a way to accomplish what I want to do?

    Thanks.

    Kim


  • 7/14/2009 11:57 AM In reply to

    Re: multiple controls and multple ASPxCallbackPanel

    Hi Kim,

    I reviewed your code and the only suspicious place I found is assignation
    of the ClientInstanceName to the ASPxCallbackPanel:

    <dxcp:ASPxCallbackPanel ... ClientInstanceName="cbSecondaryDimControl">

    If to simplify it a little, the ClientInstanceName works in the following way:
    When a control is rendered on a page, we create a client object that
    represents the control on the client side. Then, we save a reference to this
    object in the window's property with a name equal to the control's ClientInstanceName:

    window['cbSecondaryDimControl'] = new ASPxClientCallbackPanel('someContainer_CallbackPanelID');

    Then, it's possible to reference this client object by the client instance name:

    myClientInstanceName.PerformCallback(param);

    We can access window's properties using this simplified syntax specifying
    only the property name, but it's also possible to use the expanded form

    window["myClientInstanceName"].PerformCallback(param);

    If you specify the ClientIntanceName for the control that is used within
    a user control, and you place several those user controls on the page, then
    each client object will overwrite the previous one because they have the
    same ClientInstanceName:

    window['cbSecondaryDimControl'] = new ASPxClientCallbackPanel('someContainer_ID1');
    ...
    window['cbSecondaryDimControl'] = new ASPxClientCallbackPanel('someContainer_ID2');
    ...
    window['cbSecondaryDimControl'] = new ASPxClientCallbackPanel('someContainer_ID3');
    ...

    Finally, we have that the last client object can be referenced by the name
    "cbSecondaryDimControl" but all the previous ones are lost - there are no
    references to these objects.

    So you can take it as a rule that all the names within a user control must
    depend on the user control's ClientID.

    Victor
    R&D, ASP.NET Team, DevExpress

    P.S. If you wish to receive direct assistance from our Support Team, use Support Center.
  • 9/27/2009 9:55 PM In reply to

    Re: multiple controls and multple ASPxCallbackPanel

     Hi Victor,

    I have a similar problem I think:

    I have a UserControl hosted in a page. This page has an ASPxCallbackPanel define like that:

    <dxcp:ASPxCallbackPanel runat="server" ID="ASPxCallbackPanel1" ClientInstanceName="CallbackPanel">

    It's working well.

    Now I have a second ASPxCallbackPanel define in the UserControl define like that (this callbackpanel doesn't host the UserControl):

    <dxcp:ASPxCallbackPanel runat="server" ID="CallbackPanelPopup" ClientInstanceName="CallbackPanelPopup" OnCallback="CallbackPanel_Callback" ClientVisible="true" HideContentOnCallback="false" ShowLoadingPanel

    ="true">

    For this one, I cannot call the method PerformCallback properly from javascript.

    Here is the generated code from the code source: 

     

     

     

    var dxo = new ASPxClientCallbackPanel('ctl00_phContentEmp_Popup_CallbackPanelPopup');

    window[

    'CallbackPanelPopup'] = dxo;

    dxo.callBack =

    function(arg) { WebForm_DoCallback('ctl00$phContentEmp$Popup$CallbackPanelPopup', arg, aspxCallback, 'ctl00_phContentEmp_Popup_CallbackPanelPopup', aspxCallbackError, true); };

    dxo.uniqueID =

    'ctl00$phContentEmp$Popup$CallbackPanelPopup';

    dxo.EndCallback.AddHandler(

    function(s, e) { OnEndCallback(); });

     

    And here is what I try to do: 

     

    1) window[

    "ctl00_phContentEmp_Popup_CallbackPanelPopup"].PerformCallback(postponedCallbackValue);

     

    2) ctl00_phContentEmp_Popup_CallbackPanelPopup.PerformCallback(postponedCallbackValue);

    3) window["CallbackPanelPopup"].PerformCallback(postponedCallbackValue);

    The problem for 1) is "Object doesn't support this property or method"

    For 2) it is the same error: "Object doesn't support this property or method"

    And for the 3) I have this: "'window.CallbackPanelPopup' is null or not an object"

    I'm a bit confused now... am I doing something wrong, or is there an other method to call the method?

    Thanks,

    Quentin

  • 9/28/2009 3:13 AM In reply to

    Re: multiple controls and multple ASPxCallbackPanel

     All right, problem fixed... problem in the declaration of my callback.

    Cheers,

     

    Quentin

Copyright © 1998-2010 Developer Express Inc.
ALL RIGHTS RESERVED