Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET .NET C#4.0
I want to use jquery .I tried following
<script type="text/javascript">
        $(document).ready(function () {
            $("#Button1").click(function () {
                alert("Hello world!");
            });
 
<pre>
    });
&lt;/script&gt;</pre>

<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 1:44am
Comments
Sanjeev Alamuri at 23-Jan-13 6:52am
   
Microsoft JScript runtime error: '$' is undefined means, u have to add jquery.js file in YOUR HEADER tag to initialize jquery.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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="<a href="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script&gt">http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script&gt</a>;
or:
<script src="<a href="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js&quot">http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js&quot</a>; type="text/javascript"></script>


Comments
RaviRanjankr at 23-Jan-13 7:02am
   
Nice Answer. My 5+
Tadit Dash at 23-Jan-13 7:03am
   
Thanks @RaviRanjankr.
Espen Harlinn at 23-Jan-13 7:23am
   
Well answered :-D
Tadit Dash at 23-Jan-13 7:50am
   
Thanks @Espen Harlinn :P.
shivani 2013 at 23-Jan-13 7:25am
   
thanks
Tadit Dash at 23-Jan-13 7:50am
   
Most welcome. My pleasure.
Thanks for accepting the answer.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

add jquery.js file in HEADR TAG.

Download from here.

jQUERY.JS[^]
  Permalink  
Comments
shivani 2013 at 23-Jan-13 7:25am
   
thanks

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

  Print Answers RSS
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 405
2 Maciej Los 285
3 ProgramFOX 265
4 Peter Leow 210
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 405
2 Maciej Los 285
3 ProgramFOX 265
4 Peter Leow 210


Advertise | Privacy | Mobile
Web03 | 2.8.150331.1 | Last Updated 23 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100