08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 14 ■ JAVASCRIPT PROGRAMMING WITH <strong>ASP</strong>.<strong>NET</strong> <strong>AJAX</strong> 335<br />

Listing 14-1. Defining a Boat Class<br />

// JScript File<br />

Type.registerNamespace("Vehicles");<br />

Vehicles.Boat = function(boatType, boatSize, boatName)<br />

{<br />

this._boatType = boatType;<br />

this._boatSize = boatSize;<br />

this._boatName = boatName;<br />

}<br />

Vehicles.Boat.prototype =<br />

{<br />

getBoatType: function()<br />

{<br />

return(this._boatType);<br />

},<br />

getBoatSize: function()<br />

{<br />

return(this._boatSize);<br />

},<br />

getBoatName: function()<br />

{<br />

return(this._boatName);<br />

},<br />

getBoatDetails: function()<br />

{<br />

var strDetails = this._boatName + " is a "<br />

+ this._boatType + " boat that is size: "<br />

+ this._boatSize;<br />

return(strDetails);<br />

},<br />

dispose: function()<br />

{<br />

alert("destroying " + this.getBoatName());<br />

}<br />

}<br />

Vehicles.Boat.registerClass('Vehicles.Boat');<br />

To use this class in a page, create a new <strong>ASP</strong>X page containing a ScriptManager component.<br />

This ensures that the <strong>ASP</strong>.<strong>NET</strong> <strong>AJAX</strong> libraries are downloaded to the client at

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!