views:

211

answers:

4

I am getting the following error:

Microsoft JScript runtime error: 'Sys' is undefined

While trying to execute:

<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <script language="javascript" type="text/javascript">

        //ERROR IN THIS LINE!!!
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onUpdated());


          function onUpdated() {
                // get the update progress div
                var pnlPopup = $get("div2"); 
                // make it invisible

            }

    </script>
</head>
A: 

I have the same issue, plz check this thread..

http://stackoverflow.com/questions/1437799/getting-javascript-sys-is-undefined-error

I think you need to check this http://geekswithblogs.net/ranganh/archive/2007/07/15/113963.aspx

Muhammad Akhtar
+2  A: 

Ensure you have a Scriptmanager on the page and the script is below the scriptmanager. Maybe try to put your script tag into body and see what happens.

I don't know how you can fix that that its not in the body, but maybe there is a callback from Sys when its loaded

You don't need brackets to tell which function is neeeded:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onUpdated);
k0ni
I've added the JS below the scriptmanager and it worked!But I don't like the idea of having js in the body... Can something be done about that?Any way, update your answer(add what what you've posted in comment) and i will Accept it :)
dani
+1  A: 

If that is your full code, then the problem is that the Microsoft AJAX libraries aren't being included. If it isn't your full code, then you need to post more as it's a little hard to get beyond the fact that the library isn't included. Somewhere in your file -- prior to the line you are having problems with you need to have a javascript include like:

<script type="text/javascript" src="/scripts/MicrosoftAjax.js" />

As well as probably a few others.

Note: I'm talking about the generated source. Showing more complete markup would probably also suffice.

tvanfosson
The problem was placing the JS code BELOW the scrip manager...
dani
A: 

I'm a bit late to the discussion here, but a simple solution is to create a "ASP.NET AJAX-Enabled Web Site" in Visual Studio and then merge the web.config from that site with your existing site.

In this way you get all the configuration you need without having to carefully read through a lot of docs. Speed is of the essence and all that :)

Grubl3r