Solved

Problem with Ajaxcontrol

Posted on 2008-10-27
3
279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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