-1

I have nine collapsible panels on a page. I can expand or collapse them from either jQuery or C# code behind. It was all working fine until I broke something and now the $find(cpe) returns null for two of the nine.

The panels are defined and visible to the C# but their outerHTML settings in the DOM (Firebug) suggest the problem:

These work:

<input name="ctl00$body$cpOutsideSales_ClientState" id="ctl00_body_cpOutsideSales_ClientState" value="true" type="hidden">
<input name="ctl00$body$cpGeneral_ClientState" id="ctl00_body_cpGeneral_ClientState" value="false" type="hidden">

These don't work:

<input name="ctl00$body$cpDuties_ClientState" id="ctl00_body_cpDuties_ClientState" type="hidden">
<input name="ctl00$body$cpAnalyst_ClientState" id="ctl00_body_cpAnalyst_ClientState" type="hidden">

The problem is that the "value='true'" is missing, but I see no obvious way to set it. Here is a declaration of one that works:

<asp:CollapsiblePanelExtender ID="cpGeneral" runat="server" 
    TargetControlID="pnlGeneral" 
    BehaviorID="cpGeneral" 
    TextLabelID="lblGeneral" 
    SuppressPostBack="true" 
    Collapsed="true" 
    ImageControlID="icnGeneral" 
    ExpandControlID="pnlGeneralcp" 
    CollapseControlID="pnlGeneralcp"
    ExpandedText="Collapse" 
    CollapsedText="<b>Position/Organization</b>">
</asp:CollapsiblePanelExtender>

and one that doesn't:

<asp:CollapsiblePanelExtender ID="cpDuties" runat="server" 
    TargetControlID="pnlDuties"
    BehaviorID="cpDuties" 
    TextLabelID="lblDuties" 
    SuppressPostBack="true" 
    Collapsed="true"
    ImageControlID="icnDuties" 
    ExpandControlID="pnlDutiescp" 
    CollapseControlID="pnlDutiescp"
    ExpandedText="Collapse" 
    CollapsedText="<b>Duties</b>">
</asp:CollapsiblePanelExtender>

I have tried setting ClientState in C#, and the code executes, but the jQuery code still cannot find the control. I.E. This works when pn="cpGeneral" but fails when pn="cpDuties':

function addPanelHandler(panel, pn) {
    extender = $find(pn);
    if (extender != null) {
        extender.add_expanded(function () {
            loadPanel(panel, pn);
        });
    }
}

Here is an image from FireBug. Note that the "true" is missing from two of the nine: enter image description here

TonySalimi
  • 8,257
  • 4
  • 33
  • 62
Bob Jones
  • 2,049
  • 5
  • 32
  • 60
  • Hm, looking at this code snippet, I don't think we could easily find out. – kapa Oct 19 '12 at 22:27
  • 2
    You're showing us only a brick of the whole house and asking what color is the dining room ;) Please be more specific and show us more – Roko C. Buljan Oct 19 '12 at 23:28
  • I added detailed code and comments that I didn't have access to when I originally posted this. Please take another look – Bob Jones Oct 22 '12 at 16:08
  • Are you sure some other part of your code does not override the `BehaviorID` properties of those two extenders? – Frédéric Hamidi Oct 22 '12 at 18:24
  • Can you show us what the DOM looks like? Compare that with your selectors in jQuery. – andleer Oct 24 '12 at 15:41
  • At bottom of page's source you'll find `$create(Sys.Extended.UI.CollapsiblePanelBehavior` functions call for each extender. Check `id` properties values for `cpDuties` extender – Yuriy Rozhovetskiy Oct 26 '12 at 15:04

2 Answers2

0

I see no reason the two shouldn't work. I believe it is input/data related.
But because it is a fast check:
1) Try another browser. And another.
If they all behave the same way:
2) Make sure the inputs to addPanelHandler are totally correct. If they are - find someone to rubber duck the inputs and problem with.
3) If you still have the problem: ditch aspnet for the time being and copy/paste the code into HTML and distill the code. IMHO: getting rid of the server fastens up the debugging turnaround.


LosManos
  • 7,195
  • 6
  • 56
  • 107
  • 1) I have tried three different browsers with the same results. 2) I have rubber ducked this as thoroughly as I can, but the duck isn't quacking. 3) The HTML has too many references that need to be filled in by the code-behind, so this won't work either. BUT... thanks for at least making the offer to help. – Bob Jones Oct 22 '12 at 23:13
  • Ugly fix idea: Set the value property through jquery. Might have side effects. – LosManos Oct 24 '12 at 06:56
-1

I never came up with a definitive answer to what caused this, but by carefully recreating the control, I created another one that worked and gradually moved the functionality from the bad control to the good one. I was able to isolate it to something in the declaration of the control, but that's as close as I got.

Bob Jones
  • 2,049
  • 5
  • 32
  • 60