<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9173198660451518443</id><updated>2012-02-13T22:37:51.972+05:30</updated><category term='.Net Framwork 3.0'/><category term='Func'/><category term='c#'/><category term='asp.net treeview check all'/><category term='Asp.Net WebForms'/><category term='uncheck all'/><category term='javascript'/><category term='compare two objects'/><category term='value equality'/><category term='ASP.NET 2.0 Treeview'/><category term='asp.net treeview'/><category term='treeview checkboxes'/><category term='Compare objects c#'/><category term='Treeview'/><category term='collapse all'/><category term='delegates'/><category term='equality'/><category term='Treenode values'/><category term='Action'/><category term='expand/collapse all'/><category term='expand collapse all'/><category term='expand all'/><title type='text'>On .Net, Javascript and more...</title><subtitle type='html'>Home Is Where the Wind Blows</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://pushpontech.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://pushpontech.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>pushp</name><uri>http://www.blogger.com/profile/12920225024615612775</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9173198660451518443.post-8463751287704462502</id><published>2010-03-10T01:21:00.007+05:30</published><updated>2010-03-10T02:25:20.058+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='delegates'/><category scheme='http://www.blogger.com/atom/ns#' term='Action'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='Func'/><title type='text'>Leveraging new delegates in C# 3.0</title><content type='html'>&lt;p&gt;I interview a lot of developers and when I ask them about delegates there is this one answer everybody seems to know – “&lt;i&gt;delegates are nothing but function pointers&lt;/i&gt;”. Well…my friend, you will be trying hard in the next five minutes to actually point to functions, I think to myself and fire another question – “&lt;i&gt;if I give you a function, can you write me a delegate that can call the function?&lt;/i&gt;” and there you see myriads of delegate usages some of which can even stump the mighty compiler &lt;img alt="smile_regular" src="http://spaces.live.com/rte/emoticons/smile_regular.gif"&gt;. Very few can do it right. If you are getting an unusually uncomfortable feeling, it’s time to revisit this &lt;a href="http://msdn.microsoft.com/en-us/library/ms173171(VS.80).aspx"&gt;old friend&lt;/a&gt; &lt;img alt="smile_regular" src="http://spaces.live.com/rte/emoticons/smile_regular.gif"&gt;.&lt;/p&gt; &lt;p&gt;Assuming the reader is familiar with fundamental delegate concepts, let me introduce two extremely helpful delegates in the BCL - &lt;a href="http://msdn.microsoft.com/en-us/library/018hxwa8.aspx"&gt;Action&lt;/a&gt; &amp;amp; &lt;a href="http://msdn.microsoft.com/en-us/library/bb534960.aspx"&gt;Func&lt;/a&gt; . They have been used heavily in the BCL and as of .Net 4.0 each can represent functions taking up to 16 parameters (&lt;a href="http://msdn.microsoft.com/en-us/library/dd402872(VS.100).aspx"&gt;1&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/dd402862(VS.100).aspx"&gt;2&lt;/a&gt;). Let’s look at the usage of each.&lt;/p&gt; &lt;p&gt;&lt;u&gt;Func: &lt;/u&gt;Let’s see how Where extension method is defined on the IEnumerable class&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public static &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;TSource&amp;gt; Where&amp;lt;TSource&amp;gt;(&lt;span style="color: blue"&gt;this &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;TSource&amp;gt; source, &lt;span style="color: #2b91af"&gt;Func&lt;/span&gt;&amp;lt;TSource, &lt;span style="color: #2b91af"&gt;Boolean&lt;/span&gt;&amp;gt; predicate)&lt;br /&gt;{ &lt;br /&gt;    &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(TSource element &lt;span style="color: blue"&gt;in &lt;/span&gt;source) &lt;br /&gt;    { &lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(predicate(element))  &lt;br /&gt;            &lt;span style="color: blue"&gt;yield return &lt;/span&gt;element; &lt;br /&gt;    } &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The above says you can pass your own method which returns true/false based on your logic to the Where method on any class that implements IEnumerable and you will get a filtered collection back. Sample usage: we have a list of names and we want to get names starting with character ‘a’&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;&amp;gt; names = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;&amp;gt; { &lt;span style="color: #a31515"&gt;"Amit"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Raghu"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Piyush"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Ashok" &lt;/span&gt;};&lt;/pre&gt;&lt;p&gt;Our helper method would look like:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public static bool &lt;/span&gt;StartsWithA(&lt;span style="color: blue"&gt;string &lt;/span&gt;name) &lt;br /&gt;{ &lt;br /&gt;  &lt;span style="color: blue"&gt;return &lt;/span&gt;name.ToLower().StartsWith(&lt;span style="color: #a31515"&gt;"a"&lt;/span&gt;); &lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;Here is how we could achieve the result:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;namesStartingWithA = names.Where(StartsWithA);&lt;/pre&gt;&lt;p&gt;The above could be done more elegantly with the &lt;a href="http://msdn.microsoft.com/en-us/library/bb397687.aspx"&gt;lambda expression&lt;/a&gt; as:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;namesStartingWithA = names.Where(name =&amp;gt; name.ToLower().StartsWith(&lt;span style="color: #a31515"&gt;"a"&lt;/span&gt;));&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;u&gt;Action:&lt;/u&gt; I’ve long stopped writing foreach loops on collections whenever I want to get a new set of elements from the collection with some action being performed on each element. I use the ForEach extension method now, which is defined as below:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public static void &lt;/span&gt;ForEach&amp;lt;T&amp;gt;(&lt;span style="color: blue"&gt;this &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;T&amp;gt; source, &lt;span style="color: #2b91af"&gt;Action&lt;/span&gt;&amp;lt;T&amp;gt; action)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(T element &lt;span style="color: blue"&gt;in &lt;/span&gt;source)  &lt;br /&gt;        action(element); &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The above basically performs an &lt;b&gt;Action&lt;/b&gt; (supplied by the developer) on each element of a collection. Here is how we can use this in the above example for names:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;&amp;gt; namesAppendedWithZ = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;&amp;gt;(); &lt;br /&gt;names.ForEach(name =&amp;gt; namesAppendedWithZ.Add(&lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"{0}z"&lt;/span&gt;, name)));&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Lambda expression syntax is used for brevity. We can have a helper method as well to do the same job.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;Using Action delegate with events&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;If you are fond of event based programming like me (&lt;a href="http://www.dofactory.com/Patterns/PatternObserver.aspx"&gt;observer&lt;/a&gt; is my favorite pattern), &lt;b&gt;Action&lt;/b&gt; delegate can save you a lot of key strokes. Let’s consider a scenario in which we have a user control on which we can enter Employee information and create a new employee in database. We want to expose an event that can be raised on Employee successful creation and an entity (separate from the user control, e.g. the container form) interested can subscribe to the event and have access to the newly created Employee info. Below is how we can define the event leveraging the &lt;b&gt;Action&lt;/b&gt; delegate:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public event &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Employee&lt;/span&gt;&amp;gt; employeeCreatedEvent;&lt;/pre&gt;&lt;p&gt;If we are to do this in the traditional sense, we will have to define the event like this:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public event &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EventHandler&lt;/span&gt;&amp;lt;EmployeeEventArgs&amp;gt; employeeCreatedEvent;&lt;/pre&gt;&lt;p&gt;With an extra overhead of creating a new EventArgs derived class (data carrier) as below:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EmployeeEventArgs &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;EventArgs &lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Employee &lt;/span&gt;EmployeeInfo { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;I’m a lazy programmer and &lt;b&gt;Action&lt;/b&gt; delegate is a god send for guys like me &lt;img alt="smile_regular" src="http://spaces.live.com/rte/emoticons/smile_regular.gif"&gt;. Here is how the event can be raised from the user control:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;Create()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: green"&gt;//Read info from UI and fill employee dto&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Employee &lt;/span&gt;emp = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Employee &lt;/span&gt;{ID=&lt;span style="color: blue"&gt;null&lt;/span&gt;, Name=??};&lt;br /&gt;    db.CreateEmployee(emp);&lt;br /&gt;    &lt;span style="color: blue"&gt;if&lt;/span&gt;(employeeCreatedEvent != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;        employeeCreatedEvent(emp);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;And here is how it can be subscribed to on the interested component:&lt;/p&gt;&lt;pre class="code"&gt;ucEmployee.employeeCreatedEvent += &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Employee&lt;/span&gt;&amp;gt;(ucEmployee_employeeCreatedEvent);&lt;/pre&gt;&lt;p&gt;That’s all, hope this is useful.&lt;br/&gt;&lt;br /&gt;Happy Programming!!&lt;br/&gt;&lt;br /&gt;- Pushp&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9173198660451518443-8463751287704462502?l=pushpontech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pushpontech.blogspot.com/feeds/8463751287704462502/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9173198660451518443&amp;postID=8463751287704462502' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/8463751287704462502'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/8463751287704462502'/><link rel='alternate' type='text/html' href='http://pushpontech.blogspot.com/2010/03/leveraging-new-delegates-in-c-30.html' title='Leveraging new delegates in C# 3.0'/><author><name>pushp</name><uri>http://www.blogger.com/profile/12920225024615612775</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9173198660451518443.post-4862460613737047019</id><published>2009-05-07T17:15:00.004+05:30</published><updated>2009-05-08T10:09:45.799+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Compare objects c#'/><category scheme='http://www.blogger.com/atom/ns#' term='compare two objects'/><category scheme='http://www.blogger.com/atom/ns#' term='value equality'/><category scheme='http://www.blogger.com/atom/ns#' term='equality'/><title type='text'>Comparing two objects for equality [Value Equality]</title><content type='html'>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;There could be numerous implementations for comparing two objects for equality. Here is the generic implementation of the comparer I have been using:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;namespace &lt;/span&gt;Utilities&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;using &lt;/span&gt;System.Runtime.Serialization.Formatters.Binary;&lt;br /&gt;    &lt;span style="color: blue"&gt;using &lt;/span&gt;System.IO;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ComparerUtil&lt;br /&gt;    &lt;/span&gt;{&lt;br /&gt;        &lt;span style="color: blue"&gt;public static bool &lt;/span&gt;ValueEquals&amp;lt;T&amp;gt;(T lhs, T rhs)&lt;br /&gt;        &lt;span style="color: blue"&gt;where &lt;/span&gt;T : &lt;span style="color: blue"&gt;class&lt;br /&gt;        &lt;/span&gt;{&lt;br /&gt;            &lt;span style="color: #2b91af"&gt;BinaryFormatter &lt;/span&gt;formatter = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;BinaryFormatter&lt;/span&gt;();&lt;br /&gt;            &lt;span style="color: #2b91af"&gt;MemoryStream &lt;/span&gt;lhsStream = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MemoryStream&lt;/span&gt;();&lt;br /&gt;            &lt;span style="color: #2b91af"&gt;MemoryStream &lt;/span&gt;rhsStream = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MemoryStream&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;try&lt;br /&gt;            &lt;/span&gt;{&lt;br /&gt;                &lt;span style="color: blue"&gt;if &lt;/span&gt;((lhs == &lt;span style="color: blue"&gt;null&lt;/span&gt;) &amp;amp;&amp;amp; (rhs == &lt;span style="color: blue"&gt;null&lt;/span&gt;))&lt;br /&gt;                    &lt;span style="color: blue"&gt;return true&lt;/span&gt;;&lt;br /&gt;                &lt;span style="color: blue"&gt;if &lt;/span&gt;((lhs == &lt;span style="color: blue"&gt;null&lt;/span&gt;) || (rhs == &lt;span style="color: blue"&gt;null&lt;/span&gt;))&lt;br /&gt;                    &lt;span style="color: blue"&gt;return false&lt;/span&gt;;&lt;br /&gt;                formatter.Serialize(lhsStream, lhs);&lt;br /&gt;                formatter.Serialize(rhsStream, rhs);&lt;br /&gt;&lt;br /&gt;                &lt;span style="color: blue"&gt;byte&lt;/span&gt;[] lhsByteArray = lhsStream.ToArray();&lt;br /&gt;                &lt;span style="color: blue"&gt;byte&lt;/span&gt;[] rhsByteArray = rhsStream.ToArray();&lt;br /&gt;&lt;br /&gt;                &lt;span style="color: blue"&gt;return &lt;/span&gt;ArrayValueEquals(lhsByteArray, rhsByteArray);&lt;br /&gt;            }&lt;br /&gt;            &lt;span style="color: blue"&gt;finally&lt;br /&gt;            &lt;/span&gt;{&lt;br /&gt;                lhsStream.Close();&lt;br /&gt;                rhsStream.Close();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;public static bool &lt;/span&gt;ArrayValueEquals&amp;lt;T&amp;gt;(T[] lhsArray, T[] rhsArray)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(lhsArray.Length != rhsArray.Length)&lt;br /&gt;                &lt;span style="color: blue"&gt;return false&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;index = 0; index &amp;lt; lhsArray.Length; ++index)&lt;br /&gt;                &lt;span style="color: blue"&gt;if &lt;/span&gt;(!lhsArray[index].Equals(rhsArray[index]))&lt;br /&gt;                    &lt;span style="color: blue"&gt;return false&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;return true&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;The above implementation does a byte-by-byte comparison after serializing the two objects in question to binary format. This means that the two objects being compared must be &lt;b&gt;serializable&lt;/b&gt;. Note the usage of generics which are available only .Net 2.0 upwards. If you are using .Net 3.5 (which is cool ;)), consider writing the implementation using &lt;a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx" target="_blank"&gt;Extension Methods&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;Pushp&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9173198660451518443-4862460613737047019?l=pushpontech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pushpontech.blogspot.com/feeds/4862460613737047019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9173198660451518443&amp;postID=4862460613737047019' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/4862460613737047019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/4862460613737047019'/><link rel='alternate' type='text/html' href='http://pushpontech.blogspot.com/2009/05/comparing-two-objects-for-equality.html' title='Comparing two objects for equality [Value Equality]'/><author><name>pushp</name><uri>http://www.blogger.com/profile/12920225024615612775</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9173198660451518443.post-3095330403194298317</id><published>2008-09-07T19:47:00.001+05:30</published><updated>2008-09-08T22:52:40.469+05:30</updated><title type='text'>Two nifty tools to increase your productivity on windows</title><content type='html'>&lt;p&gt;While there are a number of tools to make your life hassle free on windows, the two I found very useful are below:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.launchy.net" target="_blank"&gt;Launchy&lt;/a&gt;: No more searching through your all programs to find that program whose location you d0n't exactly remember or don't care to remember. Just type first few letters of the program name and you have it, right from your desktop. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://quick.mixnmojo.com/usb-disk-ejector" target="_blank"&gt;USB Disk Ejector&lt;/a&gt;: If you keep most of your data on portable drives or happen to do a lot of plug-in and plug-out on your USB drive, this one could save you a lot of time. No more right-clicking that pathetic windows system tray icon and going through all that &amp;quot;Safe Eject&amp;quot; thing. &lt;a href="http://www.howtogeek.com/howto/windows-vista/create-a-shortcut-or-hotkey-to-immediately-eject-a-specific-usb-drive/" target="_blank"&gt;Here&lt;/a&gt; is a nice tutorial to get max out of this nice little utility.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Enjoy!!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9173198660451518443-3095330403194298317?l=pushpontech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pushpontech.blogspot.com/feeds/3095330403194298317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9173198660451518443&amp;postID=3095330403194298317' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/3095330403194298317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/3095330403194298317'/><link rel='alternate' type='text/html' href='http://pushpontech.blogspot.com/2008/09/two-nifty-tools-to-increase-your.html' title='Two nifty tools to increase your productivity on windows'/><author><name>pushp</name><uri>http://www.blogger.com/profile/12920225024615612775</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9173198660451518443.post-4094623197100209561</id><published>2008-05-20T10:35:00.015+05:30</published><updated>2010-01-02T00:19:57.145+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='Asp.Net WebForms'/><title type='text'>Leveraging Asp.Net WebForms Client Library</title><content type='html'>While working with asp.net, most front end developers have their own javascript library of utility functions like: (get/set)ElementPosition, getScroll(x/y), (add/remove)ClassName, etc. Most of the times there is no need to have your own versions of some of the more commonly used javascript utility functions as they are already present in the &lt;b&gt;Webresourse.axd&lt;/b&gt; javascript file embedded (not always) in your asp.net page and most importantly &lt;b&gt;the functions are Cross Browser&lt;/b&gt;. The utility functions in this client library are used for asp.net &lt;a href="http://msdn.microsoft.com/en-us/library/ms178208.aspx" target="_blank"&gt;callbacks&lt;/a&gt; &amp;amp; postbacks, in addition to being used by asp.net validation, treeview and menu client libraries (yes, there are seperate libraries for all these). So, if you are using asp.net menu/treeview/validators/callbacks on your webpage, you can happily use the functions provided in the library. If you want to ensure that the library is included in your page, just use a nice to have feature in your asp.net page: &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpositiononpostback.aspx" target="_blank"&gt;MaintainScrollPositionOnPostback&lt;/a&gt;:   &lt;br /&gt;  &lt;div class="code"&gt;   &lt;pre&gt;&lt;br /&gt;  &amp;lt;%@ Page Language=&amp;quot;C#&amp;quot; MaintainScrollPositionOnPostBack=&amp;quot;true&amp;quot; &lt;br /&gt;    AutoEventWireup=&amp;quot;true&amp;quot;  CodeFile=&amp;quot;Default.aspx.cs&amp;quot; Inherits=&amp;quot;_Default&amp;quot; %&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;or appliying it sitewide thru web.config as: &lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;  &lt;pre&gt;&lt;br /&gt;   &amp;lt;system.web&amp;gt;&lt;br /&gt;      &amp;lt;pages maintainScrollPositionOnPostBack=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;      &amp;lt;/pages&amp;gt;&lt;br /&gt;   &amp;lt;/system.web&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;    The script file is included in my page as: &lt;br /&gt;&lt;br /&gt;    &amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/TestWebsite/WebResource.axd?d=X2ApKqYNd-qiVRFcah5bwg2&amp;amp;t=633437918395970000&amp;quot;&amp;gt; &lt;br /&gt;&lt;br /&gt; Following is the list of some of the commonly used functions present in the library:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_GetScrollX &lt;br /&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_GetScrollY &lt;br /&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_SetElementX &lt;br /&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_SetElementY &lt;br /&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_GetElementById &lt;br /&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_SetElementWidth &lt;br /&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_SetElementHeight &lt;br /&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_RemoveClassName &lt;br /&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_AppendToClassName &lt;br /&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_GetParentByTagName &lt;br /&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_GetElementByTagName &lt;br /&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_GetElementsByTagName &lt;br /&gt;&lt;br /&gt;  &lt;img align="middle" src="http://www.dotnetscraps.com/samples/bullets/010.gif" /&gt;&amp;#160;&amp;#160;&amp;#160; WebForm_GetElementPosition - another version &lt;a href="http://www.quirksmode.org/js/findpos.html" target="_blank"&gt;here&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;  Hope this is helpful. &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;  pushp&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9173198660451518443-4094623197100209561?l=pushpontech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pushpontech.blogspot.com/feeds/4094623197100209561/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9173198660451518443&amp;postID=4094623197100209561' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/4094623197100209561'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/4094623197100209561'/><link rel='alternate' type='text/html' href='http://pushpontech.blogspot.com/2008/05/leveraging-aspnet-webforms-clent.html' title='Leveraging Asp.Net WebForms Client Library'/><author><name>pushp</name><uri>http://www.blogger.com/profile/12920225024615612775</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9173198660451518443.post-4438451915803133837</id><published>2008-04-03T01:32:00.008+05:30</published><updated>2008-04-03T03:01:30.571+05:30</updated><title type='text'>AJAX  Issues With WATIN</title><content type='html'>Recently I started Automating the UI test cases for our AJAX enabled asp.net website with &lt;a href="http://watin.sourceforge.net/"&gt;Watin&lt;/a&gt;. It was not long before that I ran into problems as Watin seems to be ajax postback agnostic.&lt;br /&gt;&lt;br /&gt;  I had a master dropdownlist and a child dropdownlist (this is disabled until something is selected in the master DDL). On the selection of an item in the master DDL there is an AJAX postback that would get data for the child DDL and then an item in the child DDL will be selected. To automate this scenario I wrote the following code:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;      IE ie = new IE("http://localhost/MySite/Default.aspx");&lt;br /&gt;      SelectList ddlMaster = ie.SelectList("ddlMaster");&lt;br /&gt;      ddlMaster.Option(Find.ByValue("India")).Select();&lt;br /&gt;      SelectList ddlChild = ie.SelectList("ddlChild");&lt;br /&gt;      ddlChild.Option(Find.ByValue("Hyderabad")).Select();&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="font-weight:bold;text-decoration:underline"&gt;The Problem&lt;/span&gt;: The first DDL gets selected perfectly and an asynchronous postback happens but I get an exception in the fourth line (which  tries to select a value in the child DDL) saying "Could not find OPTION element tag matching criteria: Attribute 'value' with value 'Hyderabad'". The problem was clear - &lt;span style="font-weight:bold;"&gt;we are trying to select a value in the child DDL before asynchronous postback is over and the child DDL is populated with values&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;The first thought that came into my mind was to put a Thread.Sleep but I know it wasn't a good solution since I can never be sure of how long the asynchronous request is going to take. So I looked for something that could tell me if page is still in async postback. Enter the &lt;a href="http://www.asp.net/ajax/documentation/live/ClientReference/Sys.WebForms/PageRequestManagerClass/default.aspx"&gt;PageRequestManager Class&lt;/a&gt; in asp.net ajax. It has a property called &lt;a href="http://www.asp.net/ajax/documentation/live/ClientReference/Sys.WebForms/PageRequestManagerClass/PageRequestManagerIsInAsyncPostbackProperty.aspx"&gt;isInAsyncPostback&lt;/a&gt; that you can query to know if page is in async postback. So all I needed was a way to run some javascript from the code and thank god, there is Eval in Watin to do just that.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;text-decoration:underline"&gt;The Solution&lt;/span&gt;: &lt;br /&gt;&lt;br /&gt;1)Updated the aspx page with a method to return true if page is in async postback as below:&lt;br /&gt;&lt;br /&gt;&lt;div class="code" style="overflow-x:scroll"&gt;&lt;pre&gt;&lt;br /&gt;    &amp;lt;asp:ScriptManager ID="scrptMgr" runat="server" EnablePartialRendering="true"&amp;gt;&lt;br /&gt;    &amp;lt;/asp:ScriptManager&amp;gt; &amp;lt;!-- script manager shown for completeness --&amp;gt;&lt;br /&gt;    &amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;      var prm = Sys.WebForms.PageRequestManager.getInstance();&lt;br /&gt;      &lt;span style="font-weight:bold;"&gt;function IsPageInAsyncPostback(){&lt;br /&gt;            return prm.get_isInAsyncPostBack();&lt;br /&gt;         }&lt;/span&gt;&lt;br /&gt;    &amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;2) Wrote a helper method to wait until async postback is complete:&lt;br /&gt;&lt;br /&gt;&lt;div class="code" style="overflow-x:scroll"&gt;&lt;pre&gt;&lt;br /&gt;   private static void WaitForAsyncPostBackToComplete(IE ie)&lt;br /&gt;      {&lt;br /&gt;          bool isInPostback = true;&lt;br /&gt;          while (isInPostback)&lt;br /&gt;          {&lt;br /&gt;             isInPostback = Convert.ToBoolean(ie.Eval("&lt;span style="font-weight:bold;"&gt;IsPageInAsyncPostback();&lt;/span&gt;"));&lt;br /&gt;             if (isInPostback)&lt;br /&gt;                 Thread.Sleep(200); //sleep for 200ms and query again&lt;br /&gt;          }&lt;br /&gt;     }&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;3) Updated the test scenario code as below:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;   IE ie = new IE("http://localhost/MySite/Default.aspx");&lt;br /&gt;   SelectList ddlMaster = ie.SelectList("ddlMaster");&lt;br /&gt;   ddlMaster.Option(Find.ByValue("India")).Select();&lt;br /&gt;   &lt;span style="font-weight:bold;"&gt;WaitForAsyncPostBackToComplete(ie);&lt;/span&gt;&lt;br /&gt;   SelectList ddlChild = ie.SelectList("ddlChild");&lt;br /&gt;   ddlChild.Option(Find.ByValue("Hyderabad")).Select();&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;and all was merry!!!&lt;br /&gt;&lt;br /&gt;Hope this is helpful.&lt;br /&gt;&lt;br /&gt;pushp&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9173198660451518443-4438451915803133837?l=pushpontech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pushpontech.blogspot.com/feeds/4438451915803133837/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9173198660451518443&amp;postID=4438451915803133837' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/4438451915803133837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/4438451915803133837'/><link rel='alternate' type='text/html' href='http://pushpontech.blogspot.com/2008/04/ajax-issues-with-watin.html' title='AJAX  Issues With WATIN'/><author><name>pushp</name><uri>http://www.blogger.com/profile/12920225024615612775</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9173198660451518443.post-2183115153144183736</id><published>2007-06-20T17:10:00.000+05:30</published><updated>2007-06-20T18:10:50.425+05:30</updated><title type='text'>Asp.Net Viewstate</title><content type='html'>One of the most neglected(in terms of understanding) and most used(functionally) features of asp.net is Viewstate. Most of the times the asp.net developer keep using viewstate feature as a black box. I don't need to tell you Viewstate can make hell lot of difference in the performance of your site, IF USED PROPERLY. &lt;br /&gt;&lt;br /&gt;The other day i stumbled upon an excellent article that tells you everything you need to know about asp.net viewstate. Check it out here: &lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx"&gt;http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Happy Programming!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9173198660451518443-2183115153144183736?l=pushpontech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pushpontech.blogspot.com/feeds/2183115153144183736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9173198660451518443&amp;postID=2183115153144183736' title='34 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/2183115153144183736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/2183115153144183736'/><link rel='alternate' type='text/html' href='http://pushpontech.blogspot.com/2007/06/aspnet-viewstate.html' title='Asp.Net Viewstate'/><author><name>pushp</name><uri>http://www.blogger.com/profile/12920225024615612775</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>34</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9173198660451518443.post-1726176000574773678</id><published>2007-06-18T14:56:00.000+05:30</published><updated>2007-06-19T09:29:36.068+05:30</updated><title type='text'>Firefox is the way to go..</title><content type='html'>This one is for those of you who have not yet embraced &lt;a linkindex="3" href="http://www.mozilla.org/"&gt;Mozilla's&lt;/a&gt; great browser &lt;a linkindex="4" href="http://www.mozilla.com/en-US/firefox/"&gt;Firefox&lt;/a&gt;. Firefox is designed for speed and security and i can assure you once you experience the power of fifefox you'll not try anything else again. Yes, the new browser from Microsoft, &lt;a linkindex="5" href="http://www.microsoft.com/windows/products/winfamily/ie/default.mspx"&gt;Internet Explorer 7&lt;/a&gt; has introduced some good features besides mimicking Firefox's &lt;a linkindex="6" href="http://www.mozilla.com/en-US/firefox/features.html"&gt;Tabbed Interface&lt;/a&gt; but it still sucks when it comes to speed. IE7 gets frustratingly slow if you open up a few tabs. Besides, firefox is having some great &lt;a set="yes" linkindex="7" href="https://addons.mozilla.org/en-US/firefox/recommended"&gt;add-ons&lt;/a&gt;(out of hundreads of add-ons available) that you would just love.&lt;br /&gt;&lt;br /&gt;Few of my favourite ones are:&lt;br /&gt;&lt;br /&gt;&lt;a linkindex="7" href="https://addons.mozilla.org/en-US/firefox/addon/2207"&gt;&lt;span style="font-weight: bold;"&gt;Cooliris Previews:&lt;/span&gt;&lt;/a&gt; This add-on allows you to preview links on a page, i.e., you can view pages pointed to by the links on the current page, directly inside your current page without leaving it.&lt;br /&gt;&lt;br /&gt;&lt;a linkindex="8" href="https://addons.mozilla.org/en-US/firefox/addon/1419"&gt;&lt;span style="font-weight: bold;"&gt;IE Tab:&lt;/span&gt;&lt;/a&gt; Some sites render properly only in IE and they would have imperfect appearance in Firefox(experienced this with MSDN site a lot). Now we have a great add-on called IE Tab that embeds IE directly in the firefox tabs. In effect IE's rendering engine is used for the sites you would like to open in IE.&lt;br /&gt;&lt;br /&gt;&lt;a set="yes" linkindex="9" href="https://addons.mozilla.org/en-US/firefox/addon/2410"&gt;&lt;span style="font-weight: bold;"&gt;FoxMarks:&lt;/span&gt;&lt;/a&gt; Take your bookmarks wherever you go.&lt;br /&gt;&lt;br /&gt;Finally, if you are a web developer &lt;a set="yes" linkindex="11" href="https://addons.mozilla.org/en-US/firefox/addon/1843"&gt;Firebug&lt;/a&gt; is indispensable.&lt;br /&gt;&lt;br /&gt;Folks, don't miss this great experience anymore...go and install &lt;a set="yes" linkindex="10" href="http://www.mozilla.com/en-US/"&gt;Firefox&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9173198660451518443-1726176000574773678?l=pushpontech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pushpontech.blogspot.com/feeds/1726176000574773678/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9173198660451518443&amp;postID=1726176000574773678' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/1726176000574773678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/1726176000574773678'/><link rel='alternate' type='text/html' href='http://pushpontech.blogspot.com/2007/06/firefox-is-way-to-go.html' title='Firefox is the way to go..'/><author><name>pushp</name><uri>http://www.blogger.com/profile/12920225024615612775</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9173198660451518443.post-679952242341154146</id><published>2007-06-18T12:33:00.000+05:30</published><updated>2007-06-18T16:08:48.796+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net Framwork 3.0'/><title type='text'>.Net Rocks</title><content type='html'>Yes, .Net Rocks...it gets amazingly better with every new release of the framework. The proof of the kind of applications that can be built using the latest release .net framework 3.0 is for all to see here: &lt;a href="http://select.nytimes.com/gst/timesreader.html"&gt;http://select.nytimes.com/gst/timesreader.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now that's cool. Hope i've that for my favourite newspaper.&lt;br /&gt;&lt;br /&gt;Hanselman calls it the &lt;a href="http://www.hanselman.com/blog/NYTimesReaderWPFsFirstKillerApp.aspx"&gt;First Killer App&lt;/a&gt; built on the latest release of .Net framework.&lt;br /&gt;&lt;br /&gt;The only hitch here is that you must have .Net framework 3.0 installed on your box, that's a prerequisite. If you're running Windows Vista, even that is not needed as Vista comes pre installed with .Net framework.&lt;br /&gt;&lt;br /&gt;Get ready to see an era of really great applications.&lt;br /&gt;&lt;br /&gt;pushp&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9173198660451518443-679952242341154146?l=pushpontech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pushpontech.blogspot.com/feeds/679952242341154146/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9173198660451518443&amp;postID=679952242341154146' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/679952242341154146'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/679952242341154146'/><link rel='alternate' type='text/html' href='http://pushpontech.blogspot.com/2007/06/net-rocks.html' title='.Net Rocks'/><author><name>pushp</name><uri>http://www.blogger.com/profile/12920225024615612775</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9173198660451518443.post-4102006474346950073</id><published>2007-06-13T10:20:00.007+05:30</published><updated>2009-02-06T00:01:07.027+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='asp.net treeview'/><category scheme='http://www.blogger.com/atom/ns#' term='Treenode values'/><title type='text'>Getting TreeNode  values on the client side with javascript</title><content type='html'>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 &lt;span style="font-weight: bold;"&gt;treenodes are rendered as anchor(&amp;lt;a ..)  tags&lt;/span&gt;) .  Getting the node's text is easy - just get hold of the node'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 &lt;span style="font-weight: bold;"&gt;href&lt;/span&gt; property for the node (provided you have not set the &lt;span style="font-weight: bold;"&gt;NavigateUrl &lt;/span&gt;property&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;for the node manually). Something like:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;href="javascript:__doPostBack('TreeView1','sRoot\\firstChild\\&lt;span style="font-weight: bold;"&gt;...\\nodeValue&lt;/span&gt;')"&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;All we have to do is to extract that bold part from what the href property gives us.&lt;br /&gt;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 - you want the value when you click a treenode. Try this:&lt;br /&gt;&lt;br /&gt;1) Add an attribute to the treeview in code behind as:&lt;br /&gt;&lt;div class="code"&gt;&lt;pre space="preserve"&gt;&lt;br /&gt;&lt;table bgcolor="#dddddd" border="0" cellpadding="16"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&lt;font color="black" face="Courier New" size="2"&gt;&lt;font color="blue"&gt;if&lt;/font&gt; (!IsPostBack)&lt;br /&gt;{&lt;br /&gt;    TreeView1.Attributes.Add(&amp;quot;onclick&amp;quot;, &amp;quot;&lt;font color="blue"&gt;return&lt;/font&gt; OnTreeClick(event)&amp;quot;);&lt;br /&gt;}&lt;br /&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;2) Put the below code in head tag of .aspx page&lt;br /&gt;&lt;div class="codeHeader"&gt;&lt;table cellpadding="0" cellspacing="0" style="width:100%"&gt; &lt;tr&gt;&lt;td style="white-space:normal"&gt;&lt;div style="display:none;color:White;padding-left:5px"&gt;Oops!! The current security settings of your browser do not allow the scripts on the page to access your clipboard.If you are using mozilla firefox, you may change security settings as follows: Type &lt;b&gt;about:config&lt;/b&gt; in the url bar and set &lt;b&gt;signed.applets.codebase_principal_support&lt;/b&gt; to &lt;b&gt;true&lt;/b&gt;. For more info, &lt;a style="color:#f9f2d5" href="http://kb.mozillazine.org/Granting_JavaScript_access_to_the_clipboard#Granting_to_signed_scripts"&gt;check here&lt;/a&gt; or contact &lt;a style="color:#f9f2d5" href="mailto:pushp.endra@yahoo.com"&gt;blog author&lt;/a&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="right"&gt;&lt;input type="button" value="Hide code" class="button" onclick="toggle(this, GetParentByTagName('div',this).nextSibling)" /&gt;&amp;nbsp;&lt;input type="button" value="Copy Code" class="button" onclick="copyCode(this, GetParentByTagName('div',this).nextSibling)" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="code"&gt;&lt;pre space="preserve" style="overflow-x:scroll;padding-bottom:5px;" &gt;&lt;br /&gt;&lt;table bgcolor="#dddddd" border="0" cellpadding="16"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&lt;font color="black" face="Courier New" size="2"&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;&lt;font color="blue"&gt;function&lt;/font&gt; OnTreeClick(evt) {&lt;br /&gt;    &lt;font color="blue"&gt;var&lt;/font&gt; src = window.event != window.undefined ? window.event.srcElement : evt.target;&lt;br /&gt;    &lt;font color="blue"&gt;var&lt;/font&gt; nodeClick = src.tagName.toLowerCase() == &amp;quot;a&amp;quot;;&lt;br /&gt;    &lt;font color="blue"&gt;if&lt;/font&gt; (nodeClick) {&lt;br /&gt;        &lt;font color="green"&gt;//innerText works in IE but fails in Firefox (I'm sick of browser anomalies), so use innerHTML as well&lt;/font&gt;&lt;br /&gt;        &lt;font color="blue"&gt;var&lt;/font&gt; nodeText = src.innerText || src.innerHTML;&lt;br /&gt;        &lt;font color="blue"&gt;var&lt;/font&gt; nodeValue = GetNodeValue(src);&lt;br /&gt;        alert(&amp;quot;Text: &amp;quot; + nodeText + &amp;quot;,&amp;quot; + &amp;quot;Value: &amp;quot; + nodeValue);&lt;br /&gt;    }&lt;br /&gt;    &lt;font color="blue"&gt;return&lt;/font&gt; &lt;font color="blue"&gt;false&lt;/font&gt;; &lt;font color="green"&gt;//comment this if you want postback on node click&lt;/font&gt;&lt;br /&gt;}&lt;br /&gt;&lt;font color="blue"&gt;function&lt;/font&gt; GetNodeValue(node) {&lt;br /&gt;    &lt;font color="blue"&gt;var&lt;/font&gt; nodeValue = &amp;quot;&amp;quot;;&lt;br /&gt;    &lt;font color="blue"&gt;var&lt;/font&gt; nodePath = node.href.substring(node.href.indexOf(&amp;quot;,&amp;quot;) + 2, node.href.length - 2);&lt;br /&gt;    &lt;font color="blue"&gt;var&lt;/font&gt; nodeValues = nodePath.split(&amp;quot;\\&amp;quot;);&lt;br /&gt;    &lt;font color="blue"&gt;if&lt;/font&gt; (nodeValues.length &amp;gt; 1)&lt;br /&gt;        nodeValue = nodeValues[nodeValues.length - 1];&lt;br /&gt;    &lt;font color="blue"&gt;else&lt;/font&gt;&lt;br /&gt;        nodeValue = nodeValues[0].substr(1);&lt;br /&gt;&lt;br /&gt;    &lt;font color="blue"&gt;return&lt;/font&gt; nodeValue;&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;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  &lt;span style="font-weight: bold;"&gt;&lt;a href="http://developer.mozilla.org/en/docs/DOM:element.nextSibling"&gt;nextSibling&lt;/a&gt;&lt;/span&gt;   property for the checkbox.&lt;br /&gt;&lt;br /&gt;That's all. Hope this is helpful.&lt;br /&gt;&lt;br /&gt;pushp&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9173198660451518443-4102006474346950073?l=pushpontech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pushpontech.blogspot.com/feeds/4102006474346950073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9173198660451518443&amp;postID=4102006474346950073' title='33 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/4102006474346950073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/4102006474346950073'/><link rel='alternate' type='text/html' href='http://pushpontech.blogspot.com/2007/06/getting-treenode-values-on-client-side.html' title='Getting TreeNode  values on the client side with javascript'/><author><name>pushp</name><uri>http://www.blogger.com/profile/12920225024615612775</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>33</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9173198660451518443.post-7527749422778975716</id><published>2007-06-05T09:46:00.003+05:30</published><updated>2008-07-25T19:27:41.106+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='expand collapse all'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET 2.0 Treeview'/><category scheme='http://www.blogger.com/atom/ns#' term='expand all'/><category scheme='http://www.blogger.com/atom/ns#' term='expand/collapse all'/><category scheme='http://www.blogger.com/atom/ns#' term='Treeview'/><category scheme='http://www.blogger.com/atom/ns#' term='collapse all'/><title type='text'>Client Side Expand/Collapse All Nodes For ASP.NET 2.0 Treeview</title><content type='html'>The asp.net treeview provides 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 me. So, I wrote some javascript that does precisely the same. Checkout the below script:&lt;br /&gt;&lt;br /&gt;&lt;div class="codeHeader"&gt;&lt;table cellpadding="0" cellspacing="0" style="width:100%"&gt; &lt;tr&gt;&lt;td style="white-space:normal"&gt;&lt;div style="display:none;color:White;padding-left:5px"&gt;Oops!! The current security settings of your browser do not allow the scripts on the page to access your clipboard.If you are using mozilla firefox, you may change security settings as follows: Type &lt;b&gt;about:config&lt;/b&gt; in the url bar and set &lt;b&gt;signed.applets.codebase_principal_support&lt;/b&gt; to &lt;b&gt;true&lt;/b&gt;. For more info, &lt;a style="color:#f9f2d5" href="http://kb.mozillazine.org/Granting_JavaScript_access_to_the_clipboard#Granting_to_signed_scripts"&gt;check here&lt;/a&gt; or contact &lt;a style="color:#f9f2d5" href="mailto:pushp.endra@yahoo.com"&gt;blog author&lt;/a&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="right"&gt;&lt;input type="button" value="Hide code" class="button" onclick="toggle(this, GetParentByTagName('div',this).nextSibling)" /&gt;&amp;nbsp;&lt;input type="button" value="Copy Code" class="button" onclick="copyCode(this, GetParentByTagName('div',this).nextSibling)" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="code"&gt;&lt;pre space="preserve" style="overflow-x:scroll;padding-bottom:5px;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;function TreeviewExpandCollapseAll(treeViewId, expandAll)&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;      var displayState = (expandAll == true ? "none" : "block");&lt;br /&gt;      var treeView = document.getElementById(treeViewId);&lt;br /&gt;      if(treeView)&lt;br /&gt;      {&lt;br /&gt;          var treeLinks = treeView.getElementsByTagName("a");&lt;br /&gt;          var nodeCount = treeLinks.length;&lt;br /&gt;               &lt;br /&gt;          for(i=0;i&amp;lt;nodeCount;i++)&lt;br /&gt;          {&lt;br /&gt;               if(treeLinks[i].firstChild.tagName)&lt;br /&gt;               {&lt;br /&gt;                   if(treeLinks[i].firstChild.tagName.toLowerCase() == "img")&lt;br /&gt;                   {&lt;br /&gt;                       var currentToggleLink = treeLinks[i];&lt;br /&gt;                       var childContainer = GetParentByTagName("table", currentToggleLink).nextSibling;&lt;br /&gt;                       if (childContainer.style.display == displayState) &lt;br /&gt;                        {&lt;br /&gt;                           eval(currentToggleLink.href);&lt;br /&gt;                        }&lt;br /&gt;                  }&lt;br /&gt;               }&lt;br /&gt;          }//for loop ends&lt;br /&gt;      }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; //utility function to get the container of an element by tagname&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;function GetParentByTagName(parentTagName, childElementObj)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;   var parent = childElementObj.parentNode;&lt;br /&gt;   while(parent.tagName.toLowerCase() != parentTagName.toLowerCase())&lt;br /&gt;   {&lt;br /&gt;      parent = parent.parentNode;&lt;br /&gt;   }&lt;br /&gt; return parent;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?id=ddzv9d87_2fs7pjg"&gt;Get Formatted Version Of Above Script&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The above script could be used as:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&amp;lt;a href="javascript:TreeviewExpandCollapseAll('&amp;lt;%=TreeView1.ClientID%&amp;gt;', &lt;b&gt;true&lt;/b&gt;)"&amp;gt;Expand All&amp;lt;/a&amp;gt;&lt;br /&gt; &amp;lt;a href="javascript:TreeviewExpandCollapseAll('&amp;lt;%=TreeView1.ClientID%&amp;gt;', &lt;b&gt;false&lt;/b&gt;)"&amp;gt;Collapse All&amp;lt;/a&amp;gt;&lt;br /&gt;     &amp;lt;asp:TreeView ID="TreeView1" .....................&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;That's all there is to it.&lt;br /&gt;&lt;br /&gt;Hope this is helpful.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Update (7/25/2008):&lt;/u&gt;&lt;/b&gt; The script has been updated to fix a minor bug concerning the toggle images being screwed up if ShowLines is false for the treeview. Thanks to comments from users, particularly to &lt;a href="http://www.blog.ryanj.com" target="_blank"&gt;ryan&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;pushp&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9173198660451518443-7527749422778975716?l=pushpontech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pushpontech.blogspot.com/feeds/7527749422778975716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9173198660451518443&amp;postID=7527749422778975716' title='21 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/7527749422778975716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/7527749422778975716'/><link rel='alternate' type='text/html' href='http://pushpontech.blogspot.com/2007/06/client-side-expandcollapse-all-nodes.html' title='Client Side Expand/Collapse All Nodes For ASP.NET 2.0 Treeview'/><author><name>pushp</name><uri>http://www.blogger.com/profile/12920225024615612775</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>21</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9173198660451518443.post-5951934167910195641</id><published>2007-06-04T11:57:00.000+05:30</published><updated>2008-01-16T12:49:06.898+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET 2.0 Treeview'/><category scheme='http://www.blogger.com/atom/ns#' term='uncheck all'/><category scheme='http://www.blogger.com/atom/ns#' term='treeview checkboxes'/><category scheme='http://www.blogger.com/atom/ns#' term='asp.net treeview check all'/><title type='text'>Asp.Net 2.0 Treeview Checkbox Check/Uncheck All script</title><content type='html'>Its a very common requirement to have the parent-child check behaviour in asp.net treeview. To define the problem:&lt;br /&gt;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).&lt;br /&gt;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....), this should happen till the root node.&lt;br /&gt;3)If a node at any level is unchecked then the parents( ma, grand ma, grand grand ma....) up to the root node must be unchecked.&lt;br /&gt;&lt;br /&gt;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've tested in IE 7 and Firefox 2.0, hope it works fine for you all.&lt;br /&gt;&lt;br /&gt;Here's how to implement it:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step 1:&lt;/b&gt;  In the page load in code behind file add an attribute to the treeview as:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;If(!isPostBack)&lt;br /&gt;{&lt;br /&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TreeView1.Attributes.Add("onclick","OnTreeClick(event)");&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;The desired affect could also be accomplished by direclty adding the attribute to the treeview tag in .aspx file as:  &lt;b&gt;&amp;lt;asp:treeview onclick="OnTreeClick(event)"... &lt;/b&gt;which would cause Visual Studio to display a warning but it works anyway but the codebehind way of doint it is the right way.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step 2:&lt;/b&gt; Put the below script in the head section of your .aspx page:&lt;br /&gt;&lt;br /&gt;&lt;div class="codeHeader"&gt;&lt;table cellpadding="0" cellspacing="0" style="width:100%"&gt; &lt;tr&gt;&lt;td style="white-space:normal"&gt;&lt;div style="display:none;color:White;padding-left:5px"&gt;Oops!! The current security settings of your browser do not allow the scripts on the page to access your clipboard.If you are using mozilla firefox, you may change security settings as follows: Type &lt;b&gt;about:config&lt;/b&gt; in the url bar and set &lt;b&gt;signed.applets.codebase_principal_support&lt;/b&gt; to &lt;b&gt;true&lt;/b&gt;. For more info, &lt;a style="color:#f9f2d5" href="http://kb.mozillazine.org/Granting_JavaScript_access_to_the_clipboard#Granting_to_signed_scripts"&gt;check here&lt;/a&gt; or contact &lt;a style="color:#f9f2d5" href="mailto:pushp.endra@yahoo.com"&gt;blog author&lt;/a&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="right"&gt;&lt;input type="button" value="Hide code" class="button" onclick="toggle(this, GetParentByTagName('div',this).nextSibling)" /&gt;&amp;nbsp;&lt;input type="button" value="Copy Code" class="button" onclick="copyCode(this, GetParentByTagName('div',this).nextSibling)" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="code"&gt;&lt;pre space="preserve" style="overflow-x:scroll;padding-bottom:5px;"&gt;&lt;br /&gt;&lt;b&gt;function OnTreeClick(evt)&lt;/b&gt;&lt;br /&gt;{&lt;br /&gt; var src = window.event != window.undefined ? window.event.srcElement : evt.target;&lt;br /&gt; var isChkBoxClick = (src.tagName.toLowerCase() == "input" &amp;&amp;amp; src.type == "checkbox");&lt;br /&gt; if(isChkBoxClick)&lt;br /&gt; {&lt;br /&gt;     var parentTable = GetParentByTagName("table", src);&lt;br /&gt;     var nxtSibling = parentTable.nextSibling;&lt;br /&gt;     //check if nxt sibling is not null &amp; is an element node&lt;br /&gt;      if(nxtSibling &amp;amp;&amp; nxtSibling.nodeType == 1)&lt;br /&gt;     {&lt;br /&gt;         if(nxtSibling.tagName.toLowerCase() == "div") //if node has children&lt;br /&gt;         {&lt;br /&gt;             //check or uncheck children at all levels&lt;br /&gt;             CheckUncheckChildren(parentTable.nextSibling, src.checked);&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt; //check or uncheck parents at all levels&lt;br /&gt; CheckUncheckParents(src, src.checked);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;b&gt; function CheckUncheckChildren(childContainer, check)&lt;/b&gt;&lt;br /&gt;{&lt;br /&gt; var childChkBoxes = childContainer.getElementsByTagName("input");&lt;br /&gt;      var childChkBoxCount = childChkBoxes.length;&lt;br /&gt; for(var i=0;i&amp;lt;childChkBoxCount;i++)&lt;br /&gt; {&lt;br /&gt;     childChkBoxes[i].checked = check;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;b&gt;function CheckUncheckParents(srcChild, check)&lt;/b&gt;&lt;br /&gt;{&lt;br /&gt; var parentDiv = GetParentByTagName("div", srcChild);&lt;br /&gt; var parentNodeTable = parentDiv.previousSibling;&lt;br /&gt; if(parentNodeTable)&lt;br /&gt; {&lt;br /&gt;     var checkUncheckSwitch;&lt;br /&gt;     if(check) //checkbox checked&lt;br /&gt;     {&lt;br /&gt;         var isAllSiblingsChecked = AreAllSiblingsChecked(srcChild);&lt;br /&gt;         if(isAllSiblingsChecked)&lt;br /&gt;                 checkUncheckSwitch = true;&lt;br /&gt;         else&lt;br /&gt;                 return; //do not need to check parent if any(one or more) child not checked&lt;br /&gt;     }&lt;br /&gt;     else //checkbox unchecked&lt;br /&gt;     {&lt;br /&gt;         checkUncheckSwitch = false;&lt;br /&gt;     }&lt;br /&gt;   &lt;br /&gt;     var inpElemsInParentTable = parentNodeTable.getElementsByTagName("input");&lt;br /&gt;     if(inpElemsInParentTable.length &gt; 0)&lt;br /&gt;     {&lt;br /&gt;         var parentNodeChkBox = inpElemsInParentTable[0];&lt;br /&gt;         parentNodeChkBox.checked = checkUncheckSwitch;&lt;br /&gt;         //do the same recursively&lt;br /&gt;        CheckUncheckParents(parentNodeChkBox, checkUncheckSwitch);&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;b&gt;function AreAllSiblingsChecked(chkBox)&lt;/b&gt;&lt;br /&gt;{&lt;br /&gt; var parentDiv = GetParentByTagName("div", chkBox);&lt;br /&gt; var childCount = parentDiv.childNodes.length;&lt;br /&gt; for(var i=0;i&amp;lt;childCount;i++)&lt;br /&gt; {&lt;br /&gt;     if(parentDiv.childNodes[i].nodeType == 1)&lt;br /&gt;     {&lt;br /&gt;         //check if the child node is an element node&lt;br /&gt;         if(parentDiv.childNodes[i].tagName.toLowerCase() == "table")&lt;br /&gt;         {&lt;br /&gt;             var prevChkBox = parentDiv.childNodes[i].getElementsByTagName("input")[0];&lt;br /&gt;             //if any of sibling nodes are not checked, return false&lt;br /&gt;             if(!prevChkBox.checked)&lt;br /&gt;             {&lt;br /&gt;                 return false;&lt;br /&gt;             }&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt; return true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//utility function to get the container of an element by tagname&lt;br /&gt;&lt;b&gt;function GetParentByTagName(parentTagName, childElementObj)&lt;/b&gt;&lt;br /&gt;{&lt;br /&gt; var parent = childElementObj.parentNode;&lt;br /&gt; while(parent.tagName.toLowerCase() != parentTagName.toLowerCase())&lt;br /&gt;     {&lt;br /&gt;         parent = parent.parentNode;&lt;br /&gt;     }&lt;br /&gt; return parent;&lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a set="yes" linkindex="1" href="http://docs.google.com/View?docid=ddzv9d87_1grc4sk"&gt;Get Formatted Version Of Above Script&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The script is pretty much self explanatory with function names saying it all.&lt;br /&gt;Comments awaited.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Footnotes: &lt;/b&gt;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 &lt;a linkindex="7" href="http://forums.asp.net/t/976122.aspx" target="_blank" class="blines3" title="Link outside of this blog"&gt;this thread&lt;/a&gt; on asp.net forums, i too have posted my solution &lt;a linkindex="8" href="http://forums.asp.net/p/976122/1733193.aspx#1733193" target="_blank" class="blines3" title="Link outside of this blog"&gt;there&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9173198660451518443-5951934167910195641?l=pushpontech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pushpontech.blogspot.com/feeds/5951934167910195641/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9173198660451518443&amp;postID=5951934167910195641' title='62 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/5951934167910195641'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9173198660451518443/posts/default/5951934167910195641'/><link rel='alternate' type='text/html' href='http://pushpontech.blogspot.com/2007/06/treeview-checkuncheck-all-script.html' title='Asp.Net 2.0 Treeview Checkbox Check/Uncheck All script'/><author><name>pushp</name><uri>http://www.blogger.com/profile/12920225024615612775</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>62</thr:total></entry></feed>
