Blogs

Paul Kimmel's Blog

Intellisense for Your JavaScript with XML Comments

     

When I first started in IT in 1987 at Underwriters, Safety & Claims in Louisville, Kentucky the PCs were just getting interesting. I was the only one that worked the second shift. My job was backing up mini-computers for the most part. In those days this still was a chore. I made a whopping $7.50 per hour. What was best about this job is that I had a lot of free time to study, access to a wide variety of computers, and Don Gardener and Mike Groher let me write some code. See, the Databus machines running Sunbelt routinely ran out of hard disk space and we’d re-write the code during long running batches to send data to another drive or fix small bugs. (Those were the days.) That was fun. In actuality what got me hooked was Quattro Pro 1, 3D charts, and the new 386SX graphics chips we got for our PCs.

In those days I spent $200 a month of my own money—remember I only made $300 a week—on computer books, books that I read cover to cover. These days I read a lot, but it is the rare book I have time to read from cover to cover. The reason for this is that I spend a lot of my free time writing books, and the reading is done pretty quickly, usually to research new topics. When writing books one is usually writing about a topic that doesn’t exist in book form as widely, which means the research is white papers, blogs, and technical manuals. I still read a lot, but it is hard to find the time to read a 1,000 page book cover to cover. However, if you are just getting started in IT, reading is the best way to learn about programming and computers. Better in some ways than college courses, for the obvious reason that college curricula follow technology but seldom lead it. Balancing books with the rigor of a college education and the discipline that requires is a wonderful balance though.

We can’t quite write about VS2010 because it is still in beta and features are evolving and protected, but you can learn about VS2008. A cool feature of VS2008 is extended Intellisense and XML comments for JavaScript. If you put your JavaScript in separate .js files and add XML comments—inside of the functions—then VS2008 will show consumers of those functions extended comment information as they are using those .js files. The following simple hello world function shows you where to place the comment—see Listing 1—and the Figure 1 shows you how Intellisense displays that information when a user is picking through commented functions.

Listing 1: A JavaScript function with an XML comment.

function HelloWorld() {
    /// <summary>XML Comments are supported in VS2008</summary>
    alert("Hello World!");
}

image
Figure 1: You can see the extended Intellisense summary displayed as I scrolll through available functions.

To reference the external .js file add script reference with the src attribute set to the external script file as shown in Listing 2.

Listing 2: Link to the external script file with the src attribute of the script tag.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="HelloWorld.js" type="text/javascript"></script>
    <script type="text/javascript">
        HelloWorld();
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>
</html>

Perhaps an interesting development we at DevExpress have to figure out is how to incorporate that Intellisense capability into our Client-Side Events Editor (see Figure 2). That would be cool.

image
Figure 2: Our client-side script editor is an easy way to add client-side script to our ASPx controls.

Published Oct 02 2009, 11:36 AM by Paul Kimmel (DevExpress)
Filed under:
Technorati tags: JavaScript
Bookmark and Share

Comments

 

Intellisense for Your JavaScript with XML Comments – Paul Kimmel's … | College Education, Books and Loans said:

Pingback from  Intellisense for Your JavaScript with XML Comments – Paul Kimmel's … | College Education, Books and Loans

October 2, 2009 4:44 PM
 

Intellisense for Your JavaScript with XML Comments - Paul Kimmel's … Scripts Rss said:

Pingback from  Intellisense for Your JavaScript with XML Comments - Paul Kimmel's … Scripts Rss

October 2, 2009 8:24 PM
 

JavaScript Countdown Timer said:

thank you very much for the tip

October 2, 2009 9:41 PM
 

Intellisense for Your bJavaScript/b with XML Comments - Paul Kimmel#39;s b…/b said:

Pingback from  Intellisense for Your bJavaScript/b with XML Comments - Paul Kimmel#39;s b…/b

October 3, 2009 4:13 AM
 

psd to css said:

great blog! Thanks!

October 3, 2009 7:23 AM
 

awake said:

I'm confused...  whats so great about this article.

It's not saying that DevExpress has figured out how to incorporate intellisense with their framework or client  side javascript produced by their controls.  It's saying the need to figure out how to.

October 3, 2009 2:57 PM
 

Brendon Muck [DX Squad] said:

$7.50 an hour in 1987? I made $8 an hour at my first programming job, and that was in 2003!

October 5, 2009 10:29 AM
 

Anna Rose said:

Thanks for the coding.....I was actually looking out for the same thing like how to insert javascript in a basic HTML file....I guess its a CSS style...<a href="ezinearticles.com <a href="www.goarticles.com/.../showa.cgi Whitening</a>

October 8, 2009 5:19 AM
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.