Click here to Skip to main content
15,880,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to use jquery .I tried following
XML
<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
Comments
Sanjeev Alamuri 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.

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:

JavaScript
<script type="text/javascript" src="/scripts/jquery.min.js"></script>


Us use a Content Delivery network like Google or Microsoft:
JavaScript
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

or:
JavaScript
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js" type="text/javascript"></script>


 
Share this answer
 
Comments
RaviRanjanKr 23-Jan-13 7:02am    
Nice Answer. My 5+
Thanks @RaviRanjankr.
Espen Harlinn 23-Jan-13 7:23am    
Well answered :-D
Thanks @Espen Harlinn :P.
shivani 2013 23-Jan-13 7:25am    
thanks
add jquery.js file in HEADR TAG.

Download from here.

jQUERY.JS[^]
 
Share this answer
 
Comments
shivani 2013 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900