Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi All

I was trying to give mouseover effect to ajaxcontrol toolkit accordion using javascript function. It worked great under normal aspx page but when i tried to use same code for my master page it gave me error ... can anyone please guide me where i am going wrong code is as below

<asp:AccordionPane  ID="AccordionPane1" runat="server">
                            <Header><span onmouseover="Openpane('0',event)">Home</span></Header>


its calling javascript as below

<pre lang="xml"><script type="text/javascript">
        function Openpane(paneIndex, eventElement) {
            var behavior = $get("Accordion1").AccordionBehavior;
            behavior.set_SelectedIndex(paneIndex);
        }
    </script>
</pre>


when i move my cursor over the accordion header it gives me AccordionBehavior' is null or not an object
error ... both the code are in master page NOT content page and javascript is in head section .....

any idea where i am going wrong ??

Thanks in advance ..
Posted
Updated 25-Oct-12 10:53am
v2
Comments
Sergey Alexandrovich Kryukov 25-Oct-12 16:52pm    
In what line? Can you run the script under debugger?
--SA
prthpatel412 25-Oct-12 16:53pm    
var behavior = $get("Accordion1").AccordionBehavior;

It simply mean $get("Accordion1") is null (not an object). If this is jQuery, the syntax is wrong, could be: jQuery.get, $.get or $.ajax. Please see:
http://api.jquery.com/jQuery.get/[^].

If this is something else, I'm not sure. You did not tag jQuery, so it can by nearly anything. For example "Accordion1" might not be in request, check up spelling. By they way, using such identifiers ("something1", "something2") is really bad; the artifact of Designer; it should be something semantic.

—SA
 
Share this answer
 
Please check the ID of the Accordin from View source.

Thanks
 
Share this answer
 
Comments
[no name] 26-Oct-12 6:11am    
my5
Try to use
$get("<%=Accordion1.ClientID%>")

instead of
$get("Accordion1")


Let me know if it doesn't work.
 
Share this answer
 
Comments
[no name] 26-Oct-12 6:11am    
my 5
prthpatel412 26-Oct-12 9:11am    
It Worked Thanks a ton man. I may sound stupid but, can u tell me whats the difference between this two syntax why it worked in normal .aspx page but not in .master ...

Thanks Santossh
Santossh 1-Nov-12 6:47am    
Usually when a control is not placed inside any of the server control, asp.net generates the clientID same as the ID provided at design time. But if the control is placed inside a server control then, the Client ID is auto generated by asp.net. Since you might have placed the accordion panel inside a ContentPlaceholder, the client ID would have been auto - generated.

Hence, its always good to access the Client ID as mentioned above.

and also, its not a stupid question, and u r welcome for any other clarification.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900