Creating a jQuery File
Before we do anything else, we need to discuss how you create an external JavaScript file and reference it in a Web Form page. Although you can add JavaScript directly to a page by wrapping it in <script>
tags, it is better to separate your client-side logic into its own file. You create a JavaScript file by selecting Website, Add New Item and selecting the Jscript File option (see Figure 40.3).
Figure 40.3. Creating a script file with Visual Web Developer.
For example, the file in Listing 40.1 contains a single JavaScript function called sayMessage()
that displays a JavaScript alert with a message.
Listing 40.1. myScript.js ...
Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.