Chapter 3. JavaScript for the ASP.NET Developer

As an ASP.NET developer, you are used to writing code using a high-level language such as C# or Visual Basic. The main development tool for .NET developers, Visual Studio, provides Intellisense that makes coding in these languages easier. Also using Visual Studio, you will find that there is rich support for debugging the code, and you get warnings and errors about many things during compilation. Visual Studio will even background-compile your code and give you updated warnings as you go to help you find problems without needing to perform an explicit compilation. The .NET Framework provides a comprehensive set of class libraries that can be used from any .NET-compatible language and helps to simplify complex programming tasks. With that said, many developers who are focused on the Web realize that writing JavaScript is an entirely different world in this regard.

This chapter introduces you to JavaScript with a bias toward the ASP.NET developer. You will see how JavaScript development is different from what you are used to with .NET languages. In addition, you will see how the browser gets JavaScript. This chapter introduces the basics of the language and explains the closure and prototype aspects of JavaScript coding, along with some techniques to apply for writing faster and more efficient JavaScript. If you look at the code of the Microsoft AJAX Library, you will see that the Microsoft ASP.NET team also uses these tactics in their JavaScript development efforts. If you are already familiar with JavaScript, you may want to skip the early sections of this chapter, where there is a core introduction of JavaScript, and instead look at some approaches for improving JavaScript code found later in the chapter.

This chapter is not meant to be an exhaustive treatment of JavaScript. There are comprehensive books and online tutorials that can take you through the language step by step and highlight differences among the minor version releases from Microsoft, Netscape, and Mozilla. I recommend Professional JavaScript for Web Developers by Nicholas C. Zakas (2005), or The JavaScript Bible by Danny Goodman and Michael Morrison (2007), both from Wiley Publishing. The goal here is to highlight the key facts and interesting aspects of the language that may be unfamiliar to someone coming from C# or Visual Basic and help you to skip some of the pitfalls that hinder development efforts or slow down JavaScript code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset