Tuesday, January 27, 2009

Intellisense for jQuery - Visual Studio 2008

Here i am going to explain on how to enable intellisense for jQuery in VS 2008.

Currently VS 2008 installation pack does not come with jQuery Intellisense. MS has plan to providing intellisense for VS 2010.

For VS 2008, MS release Hotfix for jQuery Intellisense.

Here are the steps:

Step 1:

Download hotfix and install it.


Step 2:

Download jQuery core js and doc file.

Step 3:

Add those 2 JS files in Web Site Project in same location and link those JS files in ASPX file.

After you have refered those 2 files in ASPX file, it will automatically enable Intellisense for jQuery.

CODE:

jQuery:


$(function()
{
$("#TextBox1").bind("focus", function(event)
{
if ($(this).val() == this.defaultValue)
$(this).val("");
}
);

$("#TextBox1").bind("blur", function(event)
{
if ($(this).val() == "")
$(this).val(this.defaultValue);
}
);
}
);


HTML:

First Name : <asp:TextBox ID="TextBox1" runat="server" Text="Enter First Name"></asp:TextBox>


See the screenshot: