Link to home
Create AccountLog in
Avatar of rgn2121
rgn2121Flag for United States of America

asked on

jQuery UI and ASP.Net: Microsoft JScript runtime error: Object expected

I am trying to learn about jQuery and jQuery UI and I downloaded the jQuery files and I am trying to use them but I get the error below every time.
Microsoft JScript runtime error: Object expected

The only way I don't get the error is to find a project that someone has created and download it and it works.  I have yet to add the files to my own and get it to work.

I am currently trying to use them in an asp.net website.  I have them listed in the masterpage as follows...
    <link href="css/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet"/>
    <script src="/apps/ClientScripts/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="/apps/ClientScripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>

When start the site up, it throws the error on         $(document).ready(function() {

Like I said, I am pretty new to this, so I really have no idea where to look.  I am trying to use the modal dialog and have it display on some of the pages, so the corresponding div tags are actually in the other pages...not the master page.

rgn
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

the file jquery-1.3.2.min.js is not finding
SOLUTION
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of rgn2121

ASKER

but it does exist...I clicked on the .js file from my solution explorer and drug it into the aspx window and that is the line of code created...
Avatar of rgn2121

ASKER

This is what is inside of my script tags on the masterpage...does it need to be on the individual pages that use the functions?

$(document).ready(function() {
        
                            //setup new person dialog
            $('#newPerson').dialog({
                    autoOpen: false,
                    draggable: true,
                    modal: true,
                    title: "Add New Person",
                    open: function(type, data) {
                        $(this).parent().appendTo("form");
                    }
                });

        });

        function showDialog(id) {
            $('#' + id).dialog("open");
        }

        function closeDialog(id) {
            $('#' + id).dialog("close");
        }

Open in new window

Avatar of rgn2121

ASKER

Okay...now I have tried adding the following to the master page:
<link href="css/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet"/>
    <script src="/apps/ClientScripts/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="/apps/ClientScripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>


and then inside the ContentPlaceHolder I have added:
    <script type="text/javascript">
        $(document).ready(function() {
            //setup new person dialog
            $('#newPerson').dialog({
                    autoOpen: false,
                    draggable: true,
                    modal: true,
                    title: "Add New Person",
                    open: function(type, data) {
                        $(this).parent().appendTo("form");
                    }
                });

                //setup edit person dialog
                $('#editPerson').dialog({
                    autoOpen: false,
                    draggable: true,
                    resize: false,
                    modal: true,
                    title: "Edit Person",
                    open: function(type, data) {
                        $(this).parent().appendTo("form");
                    }
                });
        });

        function showDialog(id) {
            $('#' + id).dialog("open");
        }

        function closeDialog(id) {
            $('#' + id).dialog("close");
        }
             
    </script>


The page that inherits from the masterPage is down a couple folders from the masterPage in case that has anything to do with it.

Avatar of rgn2121

ASKER

Okay, so I put all the code in my ContentPlaceHolder and everything works.  So I guess for what I was trying, the jQuery files could not be located.  The question I have now, is how to make it so that I can put them in my masterpage, and use them throughout the site?

I am guessing it will involve ResolveURL...?
Hi

So the script tag is still not working if you have it in the master page?

Regards
Avatar of rgn2121

ASKER

Not if I do what is in comment 37107519...

But I figure it is because my master page is not at the same level as the content page where I am trying to use the jQuery.  The master page is at the root, the page where I need to use the jQuery is 2 folders down and the jQuery files are 2 folders down from the root.

I placed the script source tags directly in the page I need them and it works fine, but I am also using the path that is relative to that page...
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of rgn2121

ASKER

Thanks, I will try that out and get back to you.

I have read that having the script src in the master page is over kill if I will only be using it one page since it would get loaded ofr every page in the master page.  As of right now it is only needed in one page and I have moved it there, but I still want to know for future reference...
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of rgn2121

ASKER

Thanks!
The last one is still hard coded like you had already?? :)