ASP.Net not working with JQuery in separate JS file or in HTML

J

JB

Hello Community

Using ASP.Net with a separate CSS file and separate Javascript file my
applications work fine.

Since JQuery offers features for web development I am substituting JQuery
where ever possible.

So I downloaded the JQuery library and added put it in the folder where my
old Javascript code was and added it beneath my Javascript file resides in
my html code:

<link href="CssFolder/CssScr.css" rel="stylesheet" type="text/css"/>
<script language="javascript" src="JsFolder/JsScr.js"
type="text/javascript"></script>
<script language="javascript" src=" JsFolder/jquery-1.4.2.min.js"
type="text/javascript"></script>
<script language="javascript" src=" JsFolder/jquery-1.4.js"

Next I added the following code to my JsScr.js file:

$(document).ready(function(){
$("LinkButton").click(function(){
$("p").hide();
});
});

But I got an error stating:

microsoft JScript runtime error: object expected

and the code is highlighted.


Because I got that error message I moved the JQuery code the JsScr.js and
put it under the files in my html code so now the html code looks like this:

<link href="CssFolder/CssScr.css" rel="stylesheet" type="text/css"/>
<script language="javascript" src="JsFolder/JsScr.js"
type="text/javascript"></script>
<script language="javascript" src="JsFolder/jquery-1.4.2.min.js"
type="text/javascript"></script>
<script language="javascript" src="JsFolder/jquery-1.4.js"

<script type="text/javascript">
$(document).ready(function(){
$("LinkButton").click(function(){
$("p").hide();
});
});
</script>

Now it runs the same as before but nothing happens as if the code isn’t even
there. Also this warning is present:

Warning 121 Error updating JScript IntelliSense:
C:\JQFolder\JQProj\JsFolder\jquery-1.4.2.min.js: Object doesn't support this
property or method @ 33:0 C:\ JQFolder \ JQProj \JQMenu.aspx 1 1 JQProj

I took this from a sample I saw that ran so why isn’t it running in my
application?

Thanks
Jeff
 
M

Martin Honnen

JB said:
So I downloaded the JQuery library and added put it in the folder where my
old Javascript code was and added it beneath my Javascript file resides in
my html code:

<link href="CssFolder/CssScr.css" rel="stylesheet" type="text/css"/>
<script language="javascript" src="JsFolder/JsScr.js"
type="text/javascript"></script>
<script language="javascript" src=" JsFolder/jquery-1.4.2.min.js"
type="text/javascript"></script>
<script language="javascript" src=" JsFolder/jquery-1.4.js"

Next I added the following code to my JsScr.js file:

Well the order matters, if your code in JsScr.js is supposed to use
function or objects defined in the JQuery libraries then put the <script
src="JsFolder/JsScr.js"></script> last.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top