-5

I am a beginner in jquery I have test.aspx page :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>
<script  type="text/javascript" src="jquery-1.8.2.min"></script>
<script  type="text/javascript" src="jquery.are-you-sure.js"></script>
    <script>
     $(function () {
            $('form').areYouSure();
            $('form').areYouSure({ 'message': 'Your profile details are not saved!' });
     });
        </script>
<html xmlns="http://www.w3.org/1999/xhtml">
     <!DOCTYPE html>

<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"/>
    </div>
    </form>
</body>
</html>

I get error:

ReferenceError: $ is not defined (Line #5)

I am tired to find the solution.

Mohamad Mahmoud Darwish
  • 3,865
  • 9
  • 51
  • 76
  • JQuery file is not loading – Satpal Jun 18 '14 at 11:15
  • 1
    Most likely the specified .js files are not in the location you indicated. You need to provide the correct path to them. And for goodness' sake, the ` – JLRishe Jun 18 '14 at 11:30

2 Answers2

0

The error suggesting that you don't have jquery-1.8.2.min file at the same label where your page is.

Like suppose you have file test.aspx on root folder then your script file should on root.

And if you script file is inside a folder then you need to specify the folder name

 <script  type="text/javascript" src="yourFolder/jquery-1.8.2.min"></script>
शेखर
  • 17,412
  • 13
  • 61
  • 117
0

I update the code, I was missing folder name. jquery.are-you-sure.js plugin run correctly now

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>

<!DOCTYPE html>    
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test</title>

    <script  type="text/javascript" src="Scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="JS/jquery.are-you-sure.js"></script>
    <script type="text/javascript" >
        $(function () {
            $('form').areYouSure();
            $('form').areYouSure({ 'message': 'Your profile details are not saved!' });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"/>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"/>
    </form>
</body>
</html>
Mohamad Mahmoud Darwish
  • 3,865
  • 9
  • 51
  • 76