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> 337<br />

<br />

<br />

<br />

<br />

<br />

Now you can be sure that the JavaScript framework dependencies will be downloaded<br />

<strong>and</strong> parsed prior to your custom class, so you’ll be in good shape.<br />

To test the Boat class, you can now add an HTML button to the web form, <strong>and</strong> doubleclick<br />

it to have the IDE create an event h<strong>and</strong>ler. You can then create an object from the<br />

Boat class <strong>and</strong> use it with code like this:<br />

function Button1_onclick() {<br />

var MyBoat = new Vehicles.Boat('Pedal','5','Stella');<br />

alert(MyBoat.getBoatDetails());<br />

}<br />

Listing 14-2 contains the code for the entire <strong>ASP</strong>X page.<br />

Listing 14-2. Using Custom JavaScript Class<br />

<br />

<br />

<br />

<br />

Untitled Page<br />

<br />

// <br />

<br />

<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!