Introduction: Using inheritance in
javascript.
Step:1 Open visual studio.
- Select website option and click asp.net website.
- Default.aspx page open.

Step:2 Go to solution explorer option
and right click. - Select add new items option.
- Select jscript files.

Step:3 Now we write a code in jscript
file.
Code :
Type.registerNamespace("sachin");
sachin.car = function (strmake, strmodel,
stryear) {
this._make = strmake;
this._model = strmodel;
this._year = stryear;
};
sachin.car.prototype =
{
get_make: function ()
{
return this.get_make;
},
get_model: function () {
return this.get_model;
},
get_makeandmodel: function () {
return this._make
+ "" + this._model;
},
get_year: function () {
return this.get_year;
},
dispose: function () {
alert("hi");
}
};
sachin.car.registerClass("sachin.car");
Type.registerNamespace("sachin");
sachin.ash = function (strMake, strModel,
strYear, strDriveType) {
sachin.ash.initializeBase(this,[strMake,
strModel, strYear]);
this._DriveType = strDriveType
};
sachin.ash.prototype =
{
get_DriveType: function () {
return this._DriveType;
},
dispose: function () {
alert("Disposing instance of class ash");
}
};
sachin.ash.registerClass("sachin.ash",sachin.car);
Step:4 Now again go to
solution explorer and right click.
- Add webform in asp.net page.
- Now we right a code in source.

Code:
<title>
my ajax</title>
<script language = "javascript" type
="text/javascript">
function Button1_onclick() {
var car =
new sachin.car('hero',
'driver', 'year');
alert(car.get_makeandmodel());
alert(car.get_year());
var ash =
new sachin.ash('hero',
'driver', 'year')
alert("ash make and model:" +
ash.get_makeandmodel());
alert(ash.get_year());
alert(ash.get_DriveType());
return false;
}</script>
Step :5 Now we press F5 and run a program.
