Solved

Problem with Ajaxcontrol

Posted on 2008-10-27
3
271 Views
Last Modified: 2013-11-07
I'm trying to create a collapse panel following the tutorial on Asp.net : "http://www.asp.net/learn/ajax-control-toolkit/tutorial-18-vb.aspx"
If I create it on a normal page without a Masterpage it works fine. The moment I use a Masterpage and try to use the collapse panel in a Contentpage I get a script error: 'null' is null or not an object.
I researched the web for about 1 hour to find a solution without success.

Any help is appreciated.
Thanks
Thomas
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
 

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

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Untitled Page</title> 
 

    <style type="text/css">

    .panelClass {background-color: lime; width: 300px;}

  </style>
 

  <script type="text/javascript">

        function doOpen() {

            $find("cpe")._doOpen();

        }

        function doClose() {            

            $find("cpe")._doClose();

        }

        function doToggle() {

            var cpe = $find("cpe");

            //cpe._toggle();

            if (cpe.get_Collapsed()) {

                cpe._doOpen();

            } else {

                cpe._doClose();

            }           

        }      

  </script>  

    

</head>

<body>

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

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

        <div id="MasterHeadMainBox">

	<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

            </asp:ContentPlaceHolder>

	</div>

    </form>

</body>

</html>
 

//==========================================================

//This is the code for content page

//==========================================================
 

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="testpage.aspx.vb" Inherits="testpage" %>
 

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
 

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">	

	

    <div id="BodyMainBox">

        <div id="PageMainBox">

            <input type="button" id="Button1" runat="server" value="Open" onclick="doOpen();" />

            <input type="button" id="Button2" runat="server" value="Close" onclick="doClose();" />

            <input type="button" id="Button3" runat="server" value="Toggle" onclick="doToggle();" />

            <asp:Panel ID="Panel1" CssClass="panelClass" runat="server">

                This is a test! This is a test! This is a test! This is a test!<br />

                This is a test! This is a test! This is a test!

            </asp:Panel>

            <cc1:CollapsiblePanelExtender ID="cpe" runat="server" TargetControlID="Panel1" />            

        </div>

    </div>               

</asp:Content>

Open in new window

0
Comment
Question by:tak78
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 125 total points
ID: 22815317
I'm pretty sure your javascript is not navigating down to the content page.  Perhaps something like:

function doOpen() {
            $find("ContentPlaceHolder1").$find("cpe")._doOpen();
        }


I'm seeing discussion of it several places, but not exactly a java-side solution:
0
 

Author Closing Comment

by:tak78
ID: 31510441
Thanks a lot for the hint.
0
 

Author Comment

by:tak78
ID: 22815895
Thanks Daniel. I reviewed some of the links you provided and found that the issue is that when a content page is used the names get "ctl00_ContentPlaceHolder1_" added to the original ID. So that's why it wouldn't find the object.
Well for now I used this for the fix and go tit to work:
<script type="text/javascript">

        function doOpen() {
           $find("ctl00_ContentPlaceHolder1_cpe")._doOpen();
            //$find("cpe")._doOpen();
        }
        function doClose() {
            $find("ctl00_ContentPlaceHolder1_cpe")._doClose();
            //$find("cpe")._doClose();
        }
        function doToggle() {
            var cpe = $find("ctl00_ContentPlaceHolder1_cpe")
            //var cpe = $find("cpe");
            //cpe._toggle();
            if (cpe.get_Collapsed()) {
                cpe._doOpen();
            } else {
                cpe._doClose();
            }          
        }
     
  </script>

Thanks a lot for your help and advice!!!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now