0

I am new to asp .net. I am trying to use the JQuery library scripts. So included them in my aspx page as follows

<script src="<%= Page.ResolveClientUrl("~/jquery-1.3.2.js")%>" type="text/javascript"></script>

<script src="<%= Page.ResolveClientUrl("~/jquery.validate.js")%>" type="text/javascript"></script>

<script src="<%= Page.ResolveClientUrl("~/jquery.form.js")%>" type="text/javascript"></script>

I just wrote the sample code to test the alert message.

<script language="javascript" type="text/javascript">
    $(document).ready(function() {
        alert('hi');
    });
</script>

I did not get any error when the page loaded but the alert message is not displayed. I hope I have got all the files necessary for using jquery. But I dont know why the alert message does not display. Any thoughts or comments?

4
  • 2
    What does the script src tag resolve to in the HTML? Is the location correct? Are the JS files indeed in the root of the site? Commented May 7, 2010 at 18:50
  • The view source shows up as follows <script src="jquery-1.3.2.js" type="text/javascript"></script> The scripts in the solution where located in this order: root/scripts/jquery/jqueryfiles.js Additionally it gave a javscript error that says $ is not defined. I hope it doesn't even conidered the scripts that I added. Commented May 7, 2010 at 18:55
  • Version 1.4.2 is the currently the latest. And you can use a tool like HttpWatch to see if your scripts are being loaded. Commented May 7, 2010 at 19:00
  • you probably need to change your Page.ResolveClientUrl("~/jquery-1.3.2.js") to Page.ResolveClientUrl("~/scripts/jquery/jquery-1.3.2.js")? Commented May 7, 2010 at 19:00

1 Answer 1

2

You need to do the following then for each file:

<script src='<%= Page.ResolveClientUrl("~/scripts/jquery/a-jquery-file.js")%>' 
   type='text/javascript'></script>

~/ indicates the root of the folder, so you need the additional folder structure.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.