Click here to Skip to main content
Sign Up to vote bad
good
See more: ASP.NET.NETC#4.0
I want to use jquery .I tried following
<script type="text/javascript">
        $(document).ready(function () {
            $("#Button1").click(function () {
                alert("Hello world!");
            });
 
        });
    </script>
 
<pre lang="xml"<asp:Button ID="Button1" runat="server" Text="Button" />
 

while running i am getting an error

Microsoft JScript runtime error: '$' is undefined

 

pls tell how to use jquery in asp.net
Posted 23 Jan '13 - 0:44

Comments
Sanjeev Alamuri - 23 Jan '13 - 6:52
Microsoft JScript runtime error: '$' is undefined means, u have to add jquery.js file in YOUR HEADER tag to initialize jquery.

2 solutions

You need to include the jQuery file in head section for executing the code.
How to include jQuery in ASP.Net project?[^].

You can include the script file directly in your page/master page, etc using:
 
<script type="text/javascript" src="/scripts/jquery.min.js"></script>
 
Us use a Content Delivery network like Google or Microsoft:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
or:
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js" type="text/javascript"></script>
 
  Permalink  
Comments
RaviRanjankr - 23 Jan '13 - 7:02
Nice Answer. My 5+
Tadit Dash - 23 Jan '13 - 7:03
Thanks @RaviRanjankr.
Espen Harlinn - 23 Jan '13 - 7:23
Well answered :-D
Tadit Dash - 23 Jan '13 - 7:50
Thanks @Espen Harlinn :P.
shivani 2013 - 23 Jan '13 - 7:25
thanks
Tadit Dash - 23 Jan '13 - 7:50
Most welcome. My pleasure. Thanks for accepting the answer.
add jquery.js file in HEADR TAG.
 
Download from here.
 
jQUERY.JS[^]
  Permalink  
Comments
shivani 2013 - 23 Jan '13 - 7:25
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 393
1 OriginalGriff 335
2 Arun Vasu 315
3 Maciej Los 238
4 Aarti Meswania 180
0 Sergey Alexandrovich Kryukov 9,680
1 OriginalGriff 7,539
2 CPallini 4,018
3 Rohan Leuva 3,362
4 Maciej Los 2,951


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 23 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid