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);”>
 </iframe>  
 <script type=”text/javascript” language=”javascript”>
  function resizeFrame(iframe) {
   {
    iframe.height = document.frames[iframe.id].document.body.scrollHeight + 20;    
   }
  }
    </script>
</asp:Content>

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″>
               <TemplateData>
                               <Name>
                               <Description>
                               <Icon>
                               <ProjectType>
                                              <Languages>
                                                             <Language>
                                              </Languages>
                               </ProjectType>
                               <SortOrder>
                               <DefaultName>
               </TemplateData>
               <TemplateContent>
                               <References>
                                              <Reference>
                                                             <Assembly>
                                              </Reference>
                               <ProjectItem>
                                              <SourceFile>
                                              <ReplaceParameters>
                               </ProjectItem>
               </TemplateContent>
</VSTemplate>

Example
<VSTemplate Version=”2.0.0″ xmlns=”http://schemas.microsoft.com/developer/vstemplate/2005″&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
                        <ProjectType>CSharp</ProjectType>
                        <DefaultName>Default Sample Name</DefaultName>–Default name for the File
           </TemplateData> 
            <TemplateContent>
    <References>
                          <Reference>
                                <Assembly>System</Assembly>
                </Reference>
    </References>
    <ProjectItem SubType=”Code” TargetFileName=”$fileinputname$.cs” placeParameters=”true”>SIMPLE.cs</ProjectItem>
            </TemplateContent>
</VSTemplate> 

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.