Canarys | IT Services

Blogs

How to use JQuery with Visual Studio .Net

,
Share

What does JQuery mean?

It is simply a light weight javascript library through which we can perform actions like "DOM Elements" selection, Event handling, Animation effects, Ajax calls etc with minimal code. In short we can say " write less,do more" with JQuery.

Why should we use JQuery?

  • Makes it easy to use javascript with minimal lines of code in websites.
  • Multiple browser Compatability i.e It works in almost 25+ browsers (IE,FireFox,Chrome,Safari,Netscape) unlike Javascript which behaves differently on differnt browsers.
  • There are many plugins available for programming ease.
  • It uses a chaining mechanism for DOM elements selection while developing code, which makes it more easy to write and understand in websites.
How can we use JQuery in .NET?
It is a good news to hear that Microsoft supports JQuery with intellisense for developing websites. Below lines shown how to use JQuery in asp.net.


Step 1: Jquery Reference

After downloading JQuery plugin from JQuery website ( http://www.Jquery.com )
 
 
(or)
 
We can make direct reference from Google as Google supports Jquery api.
 
 

Step 2: JQuery Intellisense for .NET

 
Basic Sample:
 
Example 1 – Display an alert box on Button click using jQuery in Asp.Net
 
Add a Button element to the page as shown below:
 
 
Now in order to tell the browser to perform some action using jQuery as soon as the document is ready or loaded, use this block:
 
     
 
Add your code in the function block
 
   
 
The same can be done in javascript like below