Monday, April 25, 2011

jQuery not working in ASP 2.0 page - Visual Web Developer 2008 Express

JQuery is not working in ASP 2.0 pages which were developed under VS 2005 and now doing Javascript in it using Visual Web Developer 2008 Express. I have included the jquery file. I have also installed all patches required. JQuery intellisense works fine in the IDE, but no jquery command is running. btw, the page renders fine from the server side coding.

Please give some remedy to this, and whats the problem in the code?

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register Src="Calendar.ascx" TagName="Calendar" TagPrefix="uc1" %>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org   /TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Control Trial Page</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />

<script language="javascript" type="text/javascript" src="Scripts/jquery-1.3.2.js">
   $(document).ready(function() {
      $("#divBody").css("display", "none");
    });
</script>
</head>
<body>
<form id="form1" runat="server">
    <div>
        <input id="showDiv" type="button" value="hi there"/> 
    </div>
    <div id="divBody">
 ....

</html>
From stackoverflow
  • You need 2 script tags. One which imports the jQuery.js file and one which contains your script. Observe:

    <script language="javascript" type="text/javascript" src="Scripts/jquery-1.3.2.js"></script>
    <script language="javascript" type="text/javascript">
        $(document).ready(function() {
            $("#divBody").css("display", "none");
        });
    </script>
    
    kk : @Ken, is it possible to use ordinary javascript while using jQuery in the same page without any adverse effects? btw, thanks for the solution.
    Ken Browning : Yes, in fact jQuery is not intended to completely abstract javascript. It's only intended to abstract parts of javascript which vary in implementation between different browsers.
  • thanks. it works fine.

    the problem was, i was using

    <script language="javascript" type="text/javascript" src="Scripts/jquery-1.3.2.js" /> 
    
    //instead of
    
    <script language="javascript" type="text/javascript" src="Scripts/jquery-1.3.2.js"> </script>
    

0 comments:

Post a Comment