CollapsiblePanelExtender not working, need help!

Last post 09-01-2008 10:20 AM by airwings17. 15 replies.

Sort Posts:

  • CollapsiblePanelExtender not working, need help!

    12-31-2007, 7:43 PM
    • Member
      point Member
    • lopez1021
    • Member since 01-01-2008, 12:27 AM
    • Posts 8

    Hello,

    this is the first time I am trying to get my hands wet implementing Ajax into an existing website. I installed the AJAX extenstions for .NET 2.0 VS 2005, and downloaded the toolkit. I watched the video on how to add a collapsible panel and I searched many discussion boards but cannot find the resoltuion to my problem.

    Problem: I have created the two panels, 1 panel is title, the other is the content. In the content panel I added a literal tag that gets populated on page load with an html document. BTW I tried just using plain text w/out the literal and problem still occurs. When I open my page, I see the content visible (don't want to see this), and when I click on the hide link, the content is still visible, when I click on it again I see that it does a brief postback and quickly closes and content appears again (doesn't stay closed). I am not sure what I am doing wrong, but I cannot get the collapsible extender to work. It does not hide my content or even stay hidden when I open this page. The weird thing is that everytime I click on the text in the title panel, that changes correctly, but nothing happens to the content. Below is the code I am trying to get to work:

     

    <body>

    <form id="form1" runat="server" class="content">

    <asp:ScriptManager ID="ScriptManager1" runat="server">

    </asp:ScriptManager>

    <div>

    <asp:Panel ID="pnlAcctDiscHeader" runat="server">

    <asp:Label ID="lblShow" runat="server" Text="Account Agreement & Disclosures Statement&nbsp;&nbsp;(Display Details...)"></asp:Label>

    </asp:Panel>

    <asp:Panel ID="pnlContent" runat="server" CssClass="collapsePanel"> --BTW the collapsePanel is set to height:0px and overflow:hidden;

    <asp:Literal ID="ltlAcctDiscPnl" runat="server"></asp:Literal>

    </asp:Panel>

    <ajaxToolkit:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server"

    Collapsed="true" TextLabelID="lblShow"

    ExpandedText="Account Agreement & Disclosures Statement&nbsp;&nbsp;(Hide Details...)"

    CollapsedText="Account Agreement & Disclosures Statement&nbsp;&nbsp;(Display Details...)"

    SuppressPostBack="true"

    ExpandControlID="pnlAcctDiscHeader"

    CollapseControlID="pnlAcctDiscHeader"

    TargetControlID="pnlContent" ScrollContents="True"

    ExpandDirection="Vertical"

    CollapsedSize="0">

    </ajaxToolkit:CollapsiblePanelExtender>

    </div>

     

    When I look at the souce code this is the js that gets generated, not sure if this looks right or not:

    <script type="text/javascript">
    <!--
    Sys.Application.initialize();
    Sys.Application.add_init(function() {
        $create(AjaxControlToolkit.CollapsiblePanelBehavior, {"ClientStateFieldID":"CollapsiblePanelExtender1_ClientState","CollapseControlID":"pnlAcctDiscHeader","Collapsed":true,"CollapsedSize":0,"CollapsedText":"Account Agreement & Disclosures Statement  (Display Details...)","ExpandControlID":"pnlAcctDiscHeader","ExpandedText":"Account Agreement & Disclosures Statement  (Hide Details...)","ScrollContents":true,"SuppressPostBack":true,"TextLabelID":"lblShow","id":"CollapsiblePanelExtender1"}, null, null, $get("pnlContent"));
    });
    // -->
    </script>

    Your help is very much appreciated!

  • Re: CollapsiblePanelExtender not working, need help!

    01-01-2008, 8:16 AM
    • Contributor
      4,243 point Contributor
    • impathan
    • Member since 07-12-2007, 10:12 AM
    • Ahmedabad
    • Posts 787

     Download here sample source code for the ajax control tool kit

    Click on 'Mark as Answer' if this post is helpful.

    ImranKhan pathan
  • Re: CollapsiblePanelExtender not working, need help!

    01-02-2008, 1:26 PM
    • Member
      point Member
    • lopez1021
    • Member since 01-01-2008, 12:27 AM
    • Posts 8

    I have the toolkit installed already and when I run the sample collapsiblepanel it works. But when I try to implement it and run it on my existing web project it doesn't.

    Ana

  • Re: CollapsiblePanelExtender not working, need help!

    01-02-2008, 1:43 PM
    • Participant
      1,293 point Participant
    • bebandit
    • Member since 04-04-2005, 8:16 PM
    • Posts 301

    Do you have the AjaxControltoolkit.dll in your bin folder??

    MCPD - Web Developer
  • Re: CollapsiblePanelExtender not working, need help!

    01-02-2008, 2:16 PM
    • Member
      point Member
    • lopez1021
    • Member since 01-01-2008, 12:27 AM
    • Posts 8

    Hi,

    yes I have the AjaxControlToolKit set as a reference and I see the dll and pdb in my bin folder of my existing project.

     Ana

  • Re: CollapsiblePanelExtender not working, need help!

    01-02-2008, 2:27 PM
    • Participant
      1,293 point Participant
    • bebandit
    • Member since 04-04-2005, 8:16 PM
    • Posts 301

    Did you drag the extender onto the form? This automatically adds a reference. What do you have for a doctype? Is it this one:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    What does happen when you click the header, or does it just show expanded out?

    Bebandit

    MCPD - Web Developer
  • Re: CollapsiblePanelExtender not working, need help!

    01-02-2008, 2:36 PM
    • Member
      point Member
    • lopez1021
    • Member since 01-01-2008, 12:27 AM
    • Posts 8

    Hi Bebandit,

    thanks for your replies. Originally I had created the toolkit reference under my toolbox, and then I dragged the extended to my form. I was having issues at the time and I thought I had to reference it, so I did that. Later I figured out the issue I was having was with the web.config. I had something wrong and then my proejct compliled.

     Here is what I have as a header:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    When I click on the header, it label text changes, but content remains open. For a split second it closes and re-opens right away. Never remains closed when I click on 'hide details'.

     Ana

  • Re: CollapsiblePanelExtender not working, need help!

    01-02-2008, 2:53 PM
    • Participant
      1,293 point Participant
    • bebandit
    • Member since 04-04-2005, 8:16 PM
    • Posts 301

    HI Ana,

    Glad you figured that first part out. Now, as far as your code, can you post something up. I am interested in these

         TargetControlID="description_ContentPanel"
            ExpandControlID="description_HeaderPanel"
            CollapseControlID="description_HeaderPanel"

    as well as how your Header Panel is set up:

    <asp:Panel ID="properties_HeaderPanel" runat="server" style="cursor: pointer;">
            <div class="heading">
                <asp:ImageButton ID="Properties_ToggleImage" runat="server" ImageUrl="~/images/expand.jpg" AlternateText="expand" />
                CollapsiblePanel Properties
            </div>
        </asp:Panel>

     

    Make sure your ExpandControlID and CollapseControlID are set to the panel and not the button in the panel.

    Bebandit

    MCPD - Web Developer
  • Re: CollapsiblePanelExtender not working, need help!

    01-02-2008, 3:03 PM
    • Member
      point Member
    • lopez1021
    • Member since 01-01-2008, 12:27 AM
    • Posts 8

    Hi,

    here is what I have currently. BTW I am not using any images. I noticed in the above sample u posted, do u have the content panel inside the header panel? I don't, see below. 

    <div>

    <asp:Panel ID="pnlAcctDiscHeader" runat="server">

    <asp:Label ID="lblShow" runat="server" Text="Account Agreement & Disclosures Statement&nbsp;&nbsp;(Display Details...)"></asp:Label>

    </asp:Panel>

    <asp:Panel ID="pnlContent" runat="server" CssClass="collapsePanel">

    Test disclosure</asp:Panel>

    <ajaxToolkit:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server"

    Collapsed="false" TextLabelID="lblShow"

    ExpandedText="Account Agreement & Disclosures Statement&nbsp;&nbsp;(Hide Details...)"

    CollapsedText="Account Agreement & Disclosures Statement&nbsp;&nbsp;(Display Details...)"

    SuppressPostBack="true"

    ExpandControlID="pnlAcctDiscHeader"

    CollapseControlID="pnlAcctDiscHeader"

    TargetControlID="pnlContent"

    ExpandDirection="Vertical"

    CollapsedSize="0">

    </ajaxToolkit:CollapsiblePanelExtender>

    </div>

  • Re: CollapsiblePanelExtender not working, need help!

    01-02-2008, 3:27 PM
    • Participant
      1,293 point Participant
    • bebandit
    • Member since 04-04-2005, 8:16 PM
    • Posts 301

    I put the exact code in my project and it works great. I think you might be having a web.config problem. The way I confirm this is to start a new Ajax enabled project and stick you code into it. If it works, you need to compare what you have in the new web.config with the web.config file of the project that doesn't work. The code is good for sure. Also, are you crossing versions (ie you have one version in your toolkit and a different one in your bin)?

     

    MCPD - Web Developer
  • Re: CollapsiblePanelExtender not working, need help!

    01-02-2008, 5:01 PM
    • Member
      point Member
    • lopez1021
    • Member since 01-01-2008, 12:27 AM
    • Posts 8

    Well atleast u validated that my code works. I used a file compare tool and compared both web.configs, so far they look good the only differences is that the web.config in my existing project has other stuff like appsettings and browsercaps. Other than that I have copied the code correctly from the sample web.config in the toolkit directory. Unfortunately after I installed the toolkit and ajax extenstions, eveytime I tried to create a new project/website, my vs.net 2005 hangs. It never did this before until I did this, so I am unable to test using a new project or even add new item. I guess I can try to re-install vs.net tomorrow when I am at the office since I don't have the cds with me. I am not sure if by re-installing vs.net maybe that will fix my issue?

    Do u have any other suggestions I can try? I noticed in the sample website in the bin folder there are some folders labeled ar, cs, de, es, etc. I don't see that on my project, could this be the reason why? If so, how do I get them to appear?

    Thanks!

    Ana

  • Re: CollapsiblePanelExtender not working, need help!

    01-02-2008, 5:10 PM
    • Participant
      1,293 point Participant
    • bebandit
    • Member since 04-04-2005, 8:16 PM
    • Posts 301

    Those extra folders are just resource files used for translating the site. You do not need them. It sounds like you might need to uninstall the AJAX 1.0 and re-install it. Also, before you do, remove the toolkit  from your toolbox and then re-install the AJAX framework. The add the toolkit back into the toolbox. Then drag the extander onto your form for a new reference. What a pain, huh?

    Bebandit

    MCPD - Web Developer
  • Re: CollapsiblePanelExtender not working, need help!

    01-02-2008, 5:48 PM
    • Member
      point Member
    • lopez1021
    • Member since 01-01-2008, 12:27 AM
    • Posts 8

    totally! Do u know if it matters where I save the toolkit, like what directory?

     Thanks!

    Ana 

  • Re: CollapsiblePanelExtender not working, need help!

    01-03-2008, 8:45 PM
    • Member
      point Member
    • lopez1021
    • Member since 01-01-2008, 12:27 AM
    • Posts 8

    Ok So I re-installed VS.NET 2005, service pack 1, and Ajax framework and toolkit. So my vs.net is working correctly. I tried my code again and it did NOT work. The weird thing is that when I create a new webform in my existing project, my code works, but in my other page it doesn't. This tells me web.config is ok, the only thing I am wondering if he has to do with the use of templates. At time master pages we're not available, so we used some controls as a header, footer, nav, and a class that inherits system.web.ui.page. I don't know how to implement AJAX in those existing pages. Any other ideas someone can give me? Thanks!

  • Re: CollapsiblePanelExtender not working, need help!

    01-04-2008, 3:37 AM
    Answer

    Hi Lopez1021,

    I have copied your sample to my project and it works.  Here is the workable sample. Would you please test it?

    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server" class="content">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            <asp:Panel ID="pnlAcctDiscHeader" runat="server">
                <asp:Label ID="lblShow" runat="server" Text="Account Agreement & Disclosures Statement  (Display Details...)"></asp:Label>
            </asp:Panel>
            <asp:Panel ID="pnlContent" runat="server" CssClass="collapsePanel">
                --BTW the collapsePanel is set to height:0px and overflow:hidden;
                <asp:Literal ID="ltlAcctDiscPnl" runat="server"></asp:Literal>
            </asp:Panel>
            <ajaxToolkit:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server"
                Collapsed="true" TextLabelID="lblShow" ExpandedText="Account Agreement & Disclosures Statement  (Hide Details...)"
                CollapsedText="Account Agreement & Disclosures Statement  (Display Details...)"
                SuppressPostBack="true" ExpandControlID="pnlAcctDiscHeader" CollapseControlID="pnlAcctDiscHeader"
                TargetControlID="pnlContent" ScrollContents="True" ExpandDirection="Vertical"
                CollapsedSize="0">
            </ajaxToolkit:CollapsiblePanelExtender>
        </div>
        </form>
    </body>
    </html>

    Please make sure <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> is added correctly or it won't work.

    If it doesn't work,  please use check your browser settings , Javascript should be enabled.  If your problem is still their , we suggest that you should use a debugging tool , such as IE Development Helper, Fiddler, HttpWatch etc, to find out whether all the js files downloaded to client successfully.  Sometimes , Firewall or some other softwares protect from downloading js files.

    Best regards,

    Jonathan

     

     
    Jonathan Shen
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 2 (16 items) 1 2 Next >