How change the height of the iframe at run time- using script

Following javascript is useful when we wants to change the height of the iframe at run time
<asp:Content ID=”ModuleContent” ContentPlaceHolderID=”ModuleContent” Runat=”Server”> 
 <iframe id=”testFrame” src =”c:\Test.html” scrolling=”no” width=”80%” height =”0″ frameborder=”0″ onload=”resizeFrame(this);”>
 <script type=”text/javascript” language=”javascript”>
  function resizeFrame(iframe) {
    iframe.height = document.frames[].document.body.scrollHeight + 20;    

Garbage Collection

Recently I had a chance to revisit the .Net framework concept ‘Garbage Collection’. It was quite interesting.
Garbage collection basically to reclaim the memory of th eobject which no longer being used.CLR(common language runtime) using the garbage collection algorithm to identify if the application is using an object or not?

How the algorithm works?
All the application has the roots( ie: static, global variable, CPU registers) the roots refer to an objects on the managed heap . The list of active roots is maintained by the just-in-time (JIT) compiler and common language runtime. Initially garbage collection assume that all the objects in the heap are garbage. Finally it assume and reclaim the memory of the obejct which doesnot have the pointer with the root.

Object In Heap

Object In Heap


Heap after garbage collection

Create and Use a Template in C#

How to create and Use a Template in C#

Template is use to create a  Skeleton for New Item(File) or project     
   1. Itemtemplate (For File)
   2. ProjectTemplate (For Project)

How to Create  ItemTemplate

1. It require Template class file (.cs)
2. vstemplate (VisualStudio Template), It is a XML file having the extension as .vstemplate

All vstemplate files must have the following format:

<VSTemplate Version=”1.1.0″>

<VSTemplate Version=”2.0.0″ xmlns=”″&gt;            <TemplateData>
                        <Name>Sample Template</Name>
                        <Description> This is the Sample Template for Testing /Description>
                        <Icon>Sample.ico</Icon>—————If u want any Icon for Template
                        <DefaultName>Default Sample Name</DefaultName>–Default name for the File
    <ProjectItem SubType=”Code” TargetFileName=”$fileinputname$.cs” placeParameters=”true”>SIMPLE.cs</ProjectItem>

Save the above file as “SIMPLE.vstemplate”

SIMPLE.cs is  class file to act as Template using the skeleton of  .vstemplate

using System;
using System.Collections;
namespace $rootnamespace$ —————————–Detect the Namespace name
    public class $safeitemname$—————————-Detect the class
                public $safeitemname$()

1 .Save the both file (SIMPLE.cs and SIMPLE.vstemplate) in to the same directory, for example SIMPLE
2. Make the above directory as a zip file. Now, we could put it in to the ItemTemplates directory \My Documents\Visual Studio 2005\Templates\ItemTemplates Drop the zip file in that folder and then load Visual Studio. Create a new project and right-click to add a new file. There you’ll see our new template, select the Template and enjoy coding.

Identify all the nodes which contains particular inner text- Using XPath

Yesterday I had a small issue to identify the entire node which contains particular inner text. I just rolled my head on that area… Initially I thought of iterating all the child node of the parent using SelectSingleNode() method of XML document class. Yes it was working fine.  I changed my view after that to use XPath.. got confused how to write a single Xpath query to identify the entire node which contains particular inner text. Finally I got the solution. Thought off share the idea. Here it is.


Sample XMl File


XmlDocument xmlDocument = new XmlDocument();
 XmlNodeList Test = xmlDocument.SelectNodes(“descendant:: Books//*[contains(text(), ‘ABC’)]”);     

The xpath execution will give 2 node counts.