troubleshooting Question

trying to collapse a div with a treeview using javascript

Avatar of xav056
xav056 asked on
11 Comments1 Solution1226 ViewsLast Modified:
I am trying to collapse a treeview used as a navigation menu on a site, tree view binds to xmldatasource, i have two DIVs defined in my body when is NAV and the second is content,
When i place a treeview control in my "NAV" div javascript function stops to work properly, i am calling setTimeout and thus it does not work properly , if i remove the treeview from my "Nav" div it works fine,
I have my javascript function doing the following on a button click it
starts collapsing the "Nav" div and Expanding the "content" Div
.aspx code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default5.aspx.vb" Inherits="Default5" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript" >
      var i=500;
      var h=200;
function collapse()

         if(i > 5)
      var v = i;
      var g= h;      
document.getElementById("NAV").style.width = v.toString()+"px";
document.getElementById("content").style.width = g.toString()+"px";


return false;
    <form id="form1" runat="server">
    <div style="width:800px; float:left;">
    <div id ="content" style="background-color:Black; width:500px; height:150px;float:left;" > 

    <div id="Nav" style="background-color:blue; width:200px; height:150px;float:left;">  
 <asp:TreeView Width="100%" ID="TreeView2" runat="server" DataSourceID="SiteMapDataSource1" BackColor="#804000" ShowExpandCollapse="False">
      <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return collapse();"   />

If i take out the <asp:treeview tag above out from the "NAV" div function behaves as expected.
Would you know what the problem might be ?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros