Skip to main content

Posts

Showing posts from January, 2010

How to add your own method/function to a .NET Framework classes

This is also called as a extension . Imagine that you are working with String Class, In there think that you want to add a your own method to the String class. So that is a extension and in .NET 3.0 introduced a way to do this using this key word. It is soo…  easy. you have to create a static class with a public modifier and write you method by using this keyword in front of the parameter. public static class MyExtensions { public static String getGreeting( this String name) { return "Hi !" + name; } } Now you can see Visual Studio shows the method for you when you use the String class.

How to Create a ASP.NET Site using Master Pages

Lets begin with a example.    This is a typical site layout that you might need to  your web site. Imagine that you are going to create a this type of layout for your pages. In the traditional way you need to create this layout for your every pages. Then imagine  if you need to change it later .. oops.. then you  need to change all the pages you have done.   But if you use master page concept it is much more easy, because you can only design the content while keeping the others static (Of cause you can also change the others too. ) In the run time master page and content are merged and will display the page.   How to do this STEP 1 : First of all you need a Web Project or a Web Application. Thus Open the visual studio and go and create a new web project. STEP 2: Then you need to add a master page to the project . thus Goto –> Add New Item and select the master page and click add button. STEP 3 : The Design your master page. < head...

How to hide/show Div content using JavaScript

< html > < head > < script language ="javascript" >   function div1() { document.all.divA.style.display = 'none' ; document.all.divB.style.display = 'block' ; } function div2() { document.all.divB.style.display = 'none' ; document.all.divA.style.display = 'block' ; } </ script > </ head > < body > < div id ="divA" onclick ="div1()" > Div One Contect </ div > < div id ="divB" onclick ="div2()" style ="display:none" > Div One Contect </ div > </ body > </ html > In using this code you can hide and show div tags. this is wrote the way only one content is available at one time.