<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>On .NET, Javascript and more..</title>
	<atom:link href="http://pushpontech.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://pushpontech.wordpress.com</link>
	<description>Home Is Where the Wind Blows</description>
	<lastBuildDate>Tue, 26 Jun 2007 11:04:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='pushpontech.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>On .NET, Javascript and more..</title>
		<link>http://pushpontech.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://pushpontech.wordpress.com/osd.xml" title="On .NET, Javascript and more.." />
	<atom:link rel='hub' href='http://pushpontech.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Blog Moved</title>
		<link>http://pushpontech.wordpress.com/2007/06/26/blog-moved/</link>
		<comments>http://pushpontech.wordpress.com/2007/06/26/blog-moved/#comments</comments>
		<pubDate>Tue, 26 Jun 2007 11:01:47 +0000</pubDate>
		<dc:creator>pushp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pushpontech.wordpress.com/2007/06/26/blog-moved/</guid>
		<description><![CDATA[This blog has moved to http://pushpontech.blogspot.com pushp<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pushpontech.wordpress.com&amp;blog=1201345&amp;post=6&amp;subd=pushpontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This blog has moved to <a href="http://pushpontech.blogspot.com">http://pushpontech.blogspot.com</a></p>
<p>pushp</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pushpontech.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pushpontech.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pushpontech.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pushpontech.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pushpontech.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pushpontech.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pushpontech.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pushpontech.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pushpontech.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pushpontech.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pushpontech.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pushpontech.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pushpontech.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pushpontech.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pushpontech.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pushpontech.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pushpontech.wordpress.com&amp;blog=1201345&amp;post=6&amp;subd=pushpontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pushpontech.wordpress.com/2007/06/26/blog-moved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6e531d4b7fefbbf789dcd5106b3d00b4?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pushp</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting TreeNode values on the client side with javascript</title>
		<link>http://pushpontech.wordpress.com/2007/06/14/getting-treenode-values-on-the-client-side-with-javascript/</link>
		<comments>http://pushpontech.wordpress.com/2007/06/14/getting-treenode-values-on-the-client-side-with-javascript/#comments</comments>
		<pubDate>Thu, 14 Jun 2007 05:51:00 +0000</pubDate>
		<dc:creator>pushp</dc:creator>
				<category><![CDATA[Client Side Programming]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://pushpontech.wordpress.com/2007/06/14/getting-treenode-values-on-the-client-side-with-javascript/</guid>
		<description><![CDATA[Update: This blog has moved to http://pushpontech.blogspot.com In a lot of scenarios it is required to get the value of a treenode (for an asp.net treeview) on the client side. While on the server we can get the nodevalue directly via the Value property of the Treenode, on the client it seems there is no [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pushpontech.wordpress.com&amp;blog=1201345&amp;post=5&amp;subd=pushpontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Update: This blog has moved to <a href="http://pushpontech.blogspot.com">http://pushpontech.blogspot.com</a></p>
<p>In a lot of scenarios it is required to get the value of a treenode (for an asp.net treeview) on the client side. While on the server we can get the nodevalue directly via the Value property of the Treenode, on the client it seems there is no corresponding attribute added to the anchor(yes <span style="font-weight:bold;">treenodes are rendered as anchor(&lt;a ..)  tags</span>) .  Getting the node&#8217;s text is easy &#8211; just get hold of the node&#8217;s anchor element and call its innerText property. But how do we get the node value? Well, if you look closely at the rendered HTML for the node, you could find the node value lurking inside the <span style="font-weight:bold;">href</span> property for the node (provided you have not set the <span style="font-weight:bold;">NavigateUrl </span>property<span style="font-weight:bold;"> </span>for the node manually). Something like:</p>
<p class="code"> href=&#8221;javascript:__doPostBack(&#8216;TreeView1&#8242;,&#8217;sRoot\\firstChild\\<span style="font-weight:bold;">&#8230;\\nodeValue</span>&#8216;)&#8221;</p>
<p>All we have to do is to extract that bold part from what the href property gives us.<br />
Whereas there may be various scenarios where we may need the node value on the client, I would demonstrate it for the case of the node click itself &#8211; you want the value when you click a treenode. Try this:</p>
<p>1) Add an attribute to the treeview in code behind as:</p>
<p style="border:1px solid gray;background-color:silver;color:black;padding-left:7px;padding-top:7px;"> if (!IsPostBack)<br />
{<br />
TreeView1.Attributes.Add(&#8220;onclick&#8221;, &#8220;return OnTreeClick(event)&#8221;);<br />
}</p>
<p>2) Put the below code in head tag of .aspx page</p>
<p style="border:1px solid gray;background-color:silver;color:black;padding-left:7px;padding-top:7px;"> &lt;script type=&#8221;text/javascript&#8221;&gt;<br />
<span style="font-weight:bold;">function OnTreeClick(evt)</span><br />
{<br />
var src = window.event != window.undefined ? window.event.srcElement : evt.target;<br />
var nodeClick = src.tagName.toLowerCase() == &#8220;a&#8221;;<br />
if(nodeClick)<br />
{<br />
var nodeText = src.innerText;<br />
var nodeValue = GetNodeValue(src);<br />
alert(&#8220;Text: &#8220;+nodeText + &#8220;,&#8221; + &#8220;Value: &#8221; + nodeValue);<br />
}<br />
//return false; //uncomment this if you do not want postback on node click<br />
}<br />
<span style="font-weight:bold;">function GetNodeValue(node)</span><br />
{<br />
//node value<br />
var nodeValue = &#8220;&#8221;;<br />
var nodePath = node.href.substring(node.href.indexOf(&#8220;,&#8221;)+2,node.href.length-2);<br />
var nodeValues = nodePath.split(&#8220;\\&#8221;);<br />
if(nodeValues.length &gt; 1)<br />
nodeValue = nodeValues[nodeValues.length - 1];<br />
else<br />
nodeValue = nodeValues[0].substr(1);       return nodeValue;<br />
}<br />
&lt;/script&gt;</p>
<p>Another scenario i can think of is when you have check boxes in the treeview and you want to get the nodevalue for the node that is checked. In that case you can just get the checkbox ( rendered as input tag) element first and then you can get the reference to the node via the  <span style="font-weight:bold;"><a href="http://developer.mozilla.org/en/docs/DOM:element.nextSibling">nextSibling</a></span>   property for the checkbox.</p>
<p>That&#8217;s all. Hope this is helpful.</p>
<p>pushp</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pushpontech.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pushpontech.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pushpontech.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pushpontech.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pushpontech.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pushpontech.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pushpontech.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pushpontech.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pushpontech.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pushpontech.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pushpontech.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pushpontech.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pushpontech.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pushpontech.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pushpontech.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pushpontech.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pushpontech.wordpress.com&amp;blog=1201345&amp;post=5&amp;subd=pushpontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pushpontech.wordpress.com/2007/06/14/getting-treenode-values-on-the-client-side-with-javascript/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6e531d4b7fefbbf789dcd5106b3d00b4?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pushp</media:title>
		</media:content>
	</item>
		<item>
		<title>Asp.Net 2.0 Treeview Checkbox Check/Uncheck All script</title>
		<link>http://pushpontech.wordpress.com/2007/06/06/aspnet-20-treeview-checkbox-checkuncheck-all-script/</link>
		<comments>http://pushpontech.wordpress.com/2007/06/06/aspnet-20-treeview-checkbox-checkuncheck-all-script/#comments</comments>
		<pubDate>Wed, 06 Jun 2007 06:20:11 +0000</pubDate>
		<dc:creator>pushp</dc:creator>
				<category><![CDATA[Client Side Programming]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://pushpontech.wordpress.com/2007/06/06/aspnet-20-treeview-checkbox-checkuncheck-all-script/</guid>
		<description><![CDATA[Update: This blog has moved to http://pushpontech.blogspot.com Its a very common requirement to have the parent-child check behaviour in asp.net treeview. To define the problem: 1)Check all the child nodes if the parent is checked and uncheck all child nodes if parent is unchecked ( well, this part is simple). 2)If a node at any [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pushpontech.wordpress.com&amp;blog=1201345&amp;post=4&amp;subd=pushpontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> This blog has moved to <a href="http://pushpontech.blogspot.com">http://pushpontech.blogspot.com</a></p>
<p>Its a very common requirement to have the parent-child check behaviour in asp.net treeview. To define the problem:<br />
1)Check all the child nodes if the parent is checked and uncheck all child nodes if parent is unchecked ( well, this part is simple).<br />
2)If a node at any level is checked and all its siblings are already checked then the parent node should be checked and the same should apply for the parent node(i.e., if its siblings are checked&#8230;.), this should happen till the root node.<br />
3)If a node at any level is unchecked then the parents( ma, grand ma, grand grand ma&#8230;.) up to the root node must be unchecked.</p>
<p>Well there have been scripts on the net that only half accomplished the task(check footnotes). So I wrote the script that solves the problem completely, upto best of my knowledge. I&#8217;ve tested in IE 7 and Firefox 2.0, hope it works fine for you all.</p>
<p>Here&#8217;s how to implement it:</p>
<p><strong>Step 1:</strong>  In the page load in code behind file add an attribute to the treeview as:</p>
<p style="border:1px solid gray;background-color:silver;color:black;padding-left:7px;padding-top:7px;"> If(!isPostBack)<br />
{<br />
TreeView1.Attributes.Add(&#8220;onclick&#8221;,&#8221;OnTreeClick(event)&#8221;);<br />
}</p>
<p>The desired affect could also be accomplished by direclty adding the attribute to the treeview tag in .aspx file as:  <strong>&lt;asp:treeview onclick=&#8221;OnTreeClick(event)&#8221;&#8230; </strong>which would cause Visual Studio to display a warning but it works anyway but the codebehind way of doint it is the right way.</p>
<p><strong>Step 2:</strong> Put the below script in the head section of your .aspx page:</p>
<p style="border:1px solid gray;background-color:silver;color:black;padding-left:7px;padding-top:7px;">   <strong>function OnTreeClick(evt)</strong><br />
{<br />
var src = window.event != window.undefined ? window.event.srcElement : evt.target;<br />
var isChkBoxClick = (src.tagName.toLowerCase() == &#8220;input&#8221; &amp;&amp; src.type == &#8220;checkbox&#8221;);<br />
if(isChkBoxClick)<br />
{<br />
var parentTable = GetParentByTagName(&#8220;table&#8221;, src);<br />
var nxtSibling = parentTable.nextSibling;<br />
//check if nxt sibling is not null &amp; is an element node<br />
if(nxtSibling &amp;&amp; nxtSibling.nodeType == 1)<br />
{<br />
if(nxtSibling.tagName.toLowerCase() == &#8220;div&#8221;) //if node has children<br />
{<br />
//check or uncheck children at all levels<br />
CheckUncheckChildren(parentTable.nextSibling, src.checked);<br />
}<br />
}<br />
//check or uncheck parents at all levels<br />
CheckUncheckParents(src, src.checked);<br />
}<br />
}<br />
<strong> function CheckUncheckChildren(childContainer, check)</strong><br />
{<br />
var childChkBoxes = childContainer.getElementsByTagName(&#8220;input&#8221;);<br />
var childChkBoxCount = childChkBoxes.length;<br />
for(var i=0;i&lt;checkBoxCount;i++)<br />
{<br />
childChkBoxes[i].checked = check;<br />
}<br />
}<br />
<strong>function CheckUncheckParents(srcChild, check)</strong><br />
{<br />
var parentDiv = GetParentByTagName(&#8220;div&#8221;, srcChild);<br />
var parentNodeTable = parentDiv.previousSibling;<br />
if(parentNodeTable)<br />
{<br />
var checkUncheckSwitch;<br />
if(check) //checkbox checked<br />
{<br />
var isAllSiblingsChecked = AreAllSiblingsChecked(srcChild);<br />
if(isAllSiblingsChecked)<br />
checkUncheckSwitch = true;<br />
else<br />
return; //do not need to check parent if any(one or more) child not checked<br />
}<br />
else //checkbox unchecked<br />
{<br />
checkUncheckSwitch = false;<br />
}var inpElemsInParentTable = parentNodeTable.getElementsByTagName(&#8220;input&#8221;);<br />
if(inpElemsInParentTable.length &gt; 0)<br />
{<br />
var parentNodeChkBox = inpElemsInParentTable[0];<br />
parentNodeChkBox.checked = checkUncheckSwitch;<br />
//do the same recursively<br />
CheckUncheckParents(parentNodeChkBox, checkUncheckSwitch);<br />
}<br />
}<br />
}<strong>function AreAllSiblingsChecked(chkBox)</strong><br />
{<br />
var parentDiv = GetParentByTagName(&#8220;div&#8221;, chkBox);<br />
var childCount = parentDiv.childNodes.length;<br />
for(var i=0;i&lt;childCount;i++)<br />
{<br />
if(parentDiv.childNodes[i].nodeType == 1)<br />
{<br />
//check if the child node is an element node<br />
if(parentDiv.childNodes[i].tagName.toLowerCase() == &#8220;table&#8221;)<br />
{<br />
var prevChkBox = parentDiv.childNodes[i].getElementsByTagName(&#8220;input&#8221;)[0];<br />
//if any of sibling nodes are not checked, return false<br />
if(!prevChkBox.checked)<br />
{<br />
return false;<br />
}<br />
}<br />
}<br />
}<br />
return true;<br />
}</p>
<p>//utility function to get the container of an element by tagname<br />
<strong>function GetParentByTagName(parentTagName, childElementObj)</strong><br />
{<br />
var parent = childElementObj.parentNode;<br />
while(parent.tagName.toLowerCase() != parentTagName.toLowerCase())<br />
{<br />
parent = parent.parentNode;<br />
}<br />
return parent;<br />
}</p>
<p><a href="http://docs.google.com/View?docid=ddzv9d87_1grc4sk">Get Formatted Version Of Above Script</a></p>
<p>The script is pretty much self explanatory with function names saying it all.<br />
Comments awaited.</p>
<p><strong>Footnotes: </strong>There has been other scripts on the net that accomplished the job only partially, the one that reached closest to doing it could be found in <a href="http://forums.asp.net/t/976122.aspx" target="_blank" class="blines3" title="Link outside of this blog">this thread</a> on asp.net forums, i too have posted my solution <a href="http://forums.asp.net/p/976122/1733193.aspx#1733193" target="_blank" class="blines3" title="Link outside of this blog">there</a>.</p>
<p>Hope this is helpful.</p>
<p>pushp</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pushpontech.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pushpontech.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pushpontech.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pushpontech.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pushpontech.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pushpontech.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pushpontech.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pushpontech.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pushpontech.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pushpontech.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pushpontech.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pushpontech.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pushpontech.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pushpontech.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pushpontech.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pushpontech.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pushpontech.wordpress.com&amp;blog=1201345&amp;post=4&amp;subd=pushpontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pushpontech.wordpress.com/2007/06/06/aspnet-20-treeview-checkbox-checkuncheck-all-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6e531d4b7fefbbf789dcd5106b3d00b4?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pushp</media:title>
		</media:content>
	</item>
		<item>
		<title>Client Side Expand/Collapse All Nodes For ASP.NET 2.0 Treeview</title>
		<link>http://pushpontech.wordpress.com/2007/06/06/client-side-expandcollapse-all-nodes-for-aspnet-20-treeview/</link>
		<comments>http://pushpontech.wordpress.com/2007/06/06/client-side-expandcollapse-all-nodes-for-aspnet-20-treeview/#comments</comments>
		<pubDate>Wed, 06 Jun 2007 06:07:58 +0000</pubDate>
		<dc:creator>pushp</dc:creator>
				<category><![CDATA[Client Side Programming]]></category>

		<guid isPermaLink="false">http://pushpontech.wordpress.com/2007/06/06/client-side-expandcollapse-all-nodes-for-aspnet-20-treeview/</guid>
		<description><![CDATA[Update: This blog has moved to http://pushpontech.blogspot.com The asp.net treeview provieds a lot of features/functions, one of which is the Expand/Collapse All functionality on the server side. The Treeview Control has got two function for doing just that: TreeView.ExpandAll(), TreeView.CollapseAll(). But going to server to accomplish such a simple functionality seemed a little odd to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pushpontech.wordpress.com&amp;blog=1201345&amp;post=3&amp;subd=pushpontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Update: This blog has moved to <a href="http://pushpontech.blogspot.com">http://pushpontech.blogspot.com</a></p>
<p>The asp.net treeview provieds a lot of features/functions, one of which is the Expand/Collapse All functionality on the server side. The Treeview Control has got two function for doing just that:<br />
TreeView.ExpandAll(), TreeView.CollapseAll(). But going to server to accomplish such a simple functionality seemed a little odd to me. So, I wrote some javascript to do the same on the client.<br />
Checkout the below script:</p>
<p style="border:1px solid gray;background-color:silver;color:black;padding-top:7px;padding-left:7px;"> <span style="font-weight:bold;">function TreeviewExpandCollapseAll(treeViewId, expandAll)</span><br />
{<br />
var displayState = (expandAll == true ? &#8220;none&#8221; : &#8220;block&#8221;);<br />
var treeView = document.getElementById(treeViewId);<br />
if(treeView)<br />
{<br />
var treeLinks = treeView.getElementsByTagName(&#8220;a&#8221;);<br />
var nodeCount = treeLinks.length;<br />
var flag = true;for(i=0;i&lt;nodeCount;i++)<br />
{<br />
if(treeLinks[i].firstChild.tagName)<br />
{<br />
if(treeLinks[i].firstChild.tagName.toLowerCase() == &#8220;img&#8221;)<br />
{<br />
var node = treeLinks[i];<br />
var level = parseInt(treeLinks[i].id.substr(treeLinks[i].id.length &#8211; 1),10);<br />
var childContainer = GetParentByTagName(&#8220;table&#8221;, node).nextSibling;if(flag)<br />
{<br />
if(childContainer.style.display == displayState)<br />
{<br />
TreeView_ToggleNode(eval(treeViewId +&#8221;_Data&#8221;),level,node,&#8217;r',childContainer);<br />
}<br />
flag = false;<br />
}<br />
else<br />
{<br />
if(childContainer.style.display == displayState)<br />
TreeView_ToggleNode(eval(treeViewId +&#8221;_Data&#8221;),level,node,&#8217;l',childContainer);<br />
}<br />
}<br />
}<br />
}//for loop ends<br />
}<br />
}//utility function to get the container of an element by tagname<br />
<strong>function GetParentByTagName(parentTagName, childElementObj)</strong><br />
{<br />
var parent = childElementObj.parentNode;<br />
while(parent.tagName.toLowerCase() != parentTagName.toLowerCase())<br />
{<br />
parent = parent.parentNode;<br />
}<br />
return parent;<br />
}</p>
<p><a href="http://docs.google.com/Doc?id=ddzv9d87_2fs7pjg">Get Formatted Version Of Above Script</a></p>
<p>The above script could be used as:</p>
<p style="border:1px solid gray;background-color:silver;color:black;padding-top:7px;padding-left:7px;">&lt;a href=&#8221;javascript:TreeviewExpandCollapseAll(&#8216;&lt;%=TreeView1.ClientID%&gt;&#8217;, true)&#8221;&gt;Expand All&lt;/a&gt;<br />
&lt;a href=&#8221;javascript:TreeviewExpandCollapseAll(&#8216;&lt;%=TreeView1.ClientID%&gt;&#8217;, false)&#8221;&gt;Collapse All&lt;/a&gt;<br />
&lt;asp:TreeView ID=&#8221;TreeView1&#8243; &#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;</p>
<p>That&#8217;s all there is to it.</p>
<p>Hope this is helpful.</p>
<p>pushp</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pushpontech.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pushpontech.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pushpontech.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pushpontech.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pushpontech.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pushpontech.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pushpontech.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pushpontech.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pushpontech.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pushpontech.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pushpontech.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pushpontech.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pushpontech.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pushpontech.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pushpontech.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pushpontech.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pushpontech.wordpress.com&amp;blog=1201345&amp;post=3&amp;subd=pushpontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pushpontech.wordpress.com/2007/06/06/client-side-expandcollapse-all-nodes-for-aspnet-20-treeview/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6e531d4b7fefbbf789dcd5106b3d00b4?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pushp</media:title>
		</media:content>
	</item>
	</channel>
</rss>
