Solved

Problem with Ajaxcontrol

Posted on 2008-10-27
3
274 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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