jQuery / "'Sys' is undefined"

Posted on 2011-03-07
Last Modified: 2012-05-11
Hi.  I am trying to use some way-cool jQuery alerts in my ASP.NET website.

One of the first alert() calls that I'm going to want to eliminate is actually called from my Page_Render() event on the server side.  It's a browser warning about IE.

After referencing this jQuery tool's js/css files and trying my app out in IE (so that it executes the RegisterClientScript() call that adds the new JS), I get this

'Sys' is undefined

error.  It happens in this part of the page's execution:

      $(document).ready(function() {
         Sys.Application.add_load(function() { Page_onLoad(); });

Does not happen in Firefox...but then, remember, it's the server-side script registration that's bombing out with the new jQuery alert() tool.  

This same server-side code does not fail with the old conventional alert() call.

Now, here's the deal.  I can use Google, and there are tons and tons of "here's how to fix this problem" sites on the net that deal with this specific error.

I CAN comb through those, and I AM combing through those now.  But I'm posting this question in an attempt to find someone who has dealt with this particular error and has specific knowledge or experience with it to help me out.

I repeat:  I can use Google, and AM using Google, so please don't just send me links.  I've tried tons and tons of "fixes", and am STILL trying them.  None have worked.  Please--I need someone with knowledge/experience specific to this problem.

Thank you!  Happy to post web.config markup, or whatever, if that helps.
Question by:bamapie
  • 3

Accepted Solution

bamapie earned 0 total points
ID: 35058975
I fixed this by adding the "$(document).ready(function() {" text around the server-side-added JS.  But I'll keep this question open in case someone has some insight more than just the workaround I'm posting.
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35060785
I haven't done much reading on jQuery, but from what I understand your solution seems to be the "correct" way, not a workaround.  Otherwise, your JavaScript runs before the jQuery libraries have been loaded - hence the Sys is not defined error.

You can accept your own response as the correct answer to this question.

Assisted Solution

bamapie earned 0 total points
ID: 35060815
OK, thanks.  It was just surprising that nothing in this equation gave me any trouble until I began using this "jquery.alerts" library.  Suddenly my registering of JS on the server was a problem...just didn't seem right.

Thanks again.

Author Closing Comment

ID: 35115345
My workaround looks to be the conventional way of doing this.  Not clear on why this suddenly became a surprise on this jquery.alerts library.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now