Showing posts with label sys. Show all posts
Showing posts with label sys. Show all posts

Wednesday, March 28, 2012

ASP.NET AJAX Incomplete Documentation

While the docs are pretty nice, nicely formatted and have some decent examples, theyre very incomplete.

Just as an example; try to find Sys.Browser anywhere on the docs site. I sure cant.

When is the documentation going to be updated and complete?

That is screwing me as well. Instead of giving us the documentation your soon here microsoft annoucing another version of ajax! also un-documented.


Thank you for this feedback, and I am sorry Sys.Browser is missing from the documentation. I will find out when documentation for Sys.Browser will be published.


Thanks again for the feedback. This class will be documented and I'll post a link to this thread when it is ready.


Gosh, if documentation of a javascript function were 'screwing' me, I'd probably go do something crazy like, I don't know, open the ajax.debug.js file and look at the available methods and their signatures.

But that's just me.

Monday, March 26, 2012

ASP.NET AJAX Beta 2 Sys errors

I've just installed and created an animation using Beta 2.0.

The problems I'm experiencing are that I'm getting the following (javascript) errors.

'Sys.Application' is null or not an object
'Sys.UI.DomEvent' is null or not an object
'Sys.Res.argumentUndefined' is null or not an object
'Sys.Res.enumValueNotInteger' is null or not an object

After searching google and the forums I've tried numerous suggestions to no avail. I've managed to narrow the cause of the errors down to a specific place. I only receive the errors when I include a couple of javascript files that have nothing to do with ASP.NET AJAX and work well without the animation in the page. The big difference with the javascript files is that they are two libraries that we use heavily in the project -- AdvancedAjax and JSON. When they are not installed the animation works perfectly. I hope you can shed some light on what I might be doing wrong.

You might want to check Scott Guthries blog - it discusses a "Sys is Undefined" error but may be related

http://weblogs.asp.net/scottgu/archive/2006/10/29/Tip_2F00_Trick_3A00_-Handling-Errors-with-the-UpdatePanel-control-using-ASP.NET-AJAX.aspx


Thanks for the quick response. However, I've already been to the link and tried the fixes mentioned there. I've also added the following snippet to my web.config to get the animation to work on some pages (pages without the advance ajax and json libraries included)

<

locationpath="ScriptResource.axd">
<system.web>
<authorization>
<allowusers="*"/>
</authorization>
</system.web>
</location>

I've followed the asp.net ajax install tutorial and have triple checked that everything that needs to be in there is in there including the

<addverb="GET"path="ScriptResource.axd"type="Microsoft.Web.Handlers.ScriptResourceHandler"validate="false"/>


Where in the web.config did you add that snipet?
just above the </configuration> at the end of the web.config...

The handler in the httphandlers section

<httpHandlers >
<removeverb="*"path="*.asmx" />
<addverb="*"path="*.asmx"validate="false"type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<addverb="GET"path="ScriptResource.axd"type="Microsoft.Web.Handlers.ScriptResourceHandler"validate="false" />
</httpHandlers>

And the

<locationpath="ScriptResource.axd" >
<system.web >
<authorization >
<allowusers="*" />
</authorization >
</system.web >
</location>

Like jody said, at the very end before the </config> and after the asp.net ajax </system.WebServer> tag

I've also tried adding my javascript files to the script manager and notifying Sys.Application by following the following located at [here (pops in new win)]. This did not work either, the same problems happened that I first posted about.



<asp:ScriptManagerrunat="server"ID="ScriptManager1">
<Scripts>
<asp:ScriptReferencePath="~/scripts/script_file1.js"/>
<asp:ScriptReferencePath="~/scripts/script_file2.js"/>
</Scripts>
</asp:ScriptManager>

After upgrading to Beta 2, any functionality that needs to use functions inside those files, was giving errors?!

After reading the"Changes between the ASP.NET AJAX ("Atlas") CTP and the Beta 2 and RTM Releases", I come to know that every external Javascript files that being referenced from ScriptManager must have a call toSys.Application.notifyScriptLoader; this will notify the Sys.Applicationthat the script files has been downloaded to the client computer, so for each external .js file add the following snippet:

if(typeof(Sys) !== "undefined")Sys.Application.notifyScriptLoaded();

Another solution thatAlessandro Gallo hasblog it is to add the following snippet to the end of each .js file:

if(Sys &&Sys.Application) {Sys.Application.notifyScriptLoaded();}


I was investigating the same bunch of Sys.Application errors on my website and couldn't solve the issue until I found the thread. I checked my .js files and added the aforementioned code to the end of each but the error still continued to show up. So I decided to remove blocks of code from one .js file to see if any of them cause any problem. And I found a piece that caused the problem!

I have the following code:

Object.prototype.startsFrom = startsFrom;

function startsFrom ( s2 )
{
return (this.toString().substring(0, s2.length) == s2 )
}

As soon I comment this piece out (it's enough to comment the first line of the piece), the errors are gone!

So if anyone has the same problem - check for this "Object.prototype..." kind of code in your .js files!

Hope this helps.

Vlad.


If your namespaces begin with Microsoft.Web.* (as I see some of the examples here doing), then you're pointing to the wrong ASP.NET AJAX version, I think. The 1.0 release of ASP.NET AJAX uses the System.Web.* namespace and web.config settings need to be set accordingly. Starting from the web.config that comes with ASP.NET AJAX or the Toolkit should get things off on the right foot.

Probably an error takes place because you are using a DatePicker or somecontrol that uses Javascript and that interferes with Ajax.NET.

Verify that you arent using other Javascript.

ASP.NET AJAX and urlMapping bug

A page will error out with "Sys.WebForms.PageRequestManagerServerErrorException: An unkown error occurred while processing the request on the server. The status code returned from the server was: 12031" when an update panel is updating for the second update. In other words, the first AJAX-style page update works fine, but the second one causes this error.

I've narrowed down the problem to urlMappings in the web.config file. I'm using it to control role-based access. When the page name doesn't match the source page name, the error occurs. For example, this works:

<urlMappings>
<add url="~/folder/Default2.aspx" mappedUrl="~/Default2.aspx"/>
</urlMappings>

While this doesn't:

<urlMappings>
<add url="~/folder/edit.aspx" mappedUrl="~/Default2.aspx"/>
</urlMappings>

Here's a project showing an example of the error in action. Master page:

<%@dotnet.itags.org. Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<ajax:ScriptManager runat="server" ID="SM1" />
<div class="header">
Sweet header text.
</div>
<asp:HyperLink runat="server" ID="HL1" NavigateUrl="~/folder/edit.aspx" Text="Page doesn't really exist!" /><br />
<asp:HyperLink runat="server" ID="HL2" NavigateUrl="~/Default.aspx" Text="Default page." /><br />
<b>Content begins:<br /></b><br /><br />
<ajax:UpdatePanel runat="server" ID="upanel1">
<ContentTemplate>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server" />
</ContentTemplate>
</ajax:UpdatePanel>
<br /><b>Content ended.</b><br /><br /
</div>
</form>
</body>
</html>

Default.aspx:

<%@dotnet.itags.org. Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
This page is ~/Default.aspx.
</asp:Content>

Default2.aspx:

<%@dotnet.itags.org. Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
This page is ~/Default2.aspx.<br />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true">
<asp:ListItem Text="Show label one" Value="1" />
<asp:ListItem Text="Show label two" Value="2" />
</asp:DropDownList>
<br />
<asp:Label ID="Label1" runat="server" Text="Label one" Visible="false" />
<asp:Label ID="Label2" runat="server" Text="Label two" Visible="false" />
</asp:Content>

Default2.aspx.vb:

PartialClass Default2
Inherits System.Web.UI.Page

Protected Sub DropDownList1_SelectedIndexChanged(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles DropDownList1.SelectedIndexChanged
If DropDownList1.SelectedValue ="1"Then Label1.Visible =True Label2.Visible =False
Else Label1.Visible =False Label2.Visible =True
End If
End Sub
End Class

Make a folder called "folder" in the root of the project and add this to the web.config, under system.web:

<urlMappings>
<add url="~/folder/edit.aspx" mappedUrl="~/Default2.aspx"/>
</urlMappings>

To see the bug, fire up the project and click the "Page doesn't really exist" link. This will bring you to the mapped page. Change the dropdownlist's selection, notice the label change, then change the selection on the DDL again. You'll get the error I specified earlier. Fiddler shows the AJAX call attempting to read folder/Default2.aspx instead of the correct URL, causing a 404 and the callback to fail.

Any idea for a fix on this one? It can be worked around by keeping the page names consistent, but that doesn't fix the bug.

Did you ever find a solution to this. My setup is not the same, but I am getting the same error.

Saturday, March 24, 2012

ASP.NET 2.0 AJAX WIndows 2003 Server - SYS UNDEFINED ERROR

I am developing one of my web sites where I am trying to implement AJAX and when I deploy it to Windows 2003 server with IIS 7, I get sys undefined JavaScript error. I searched every article on Google and did not find solution to solve it.

I am using ASP.NET 2 AJAX on IIS 7, Windows 2003 platform.

Web site where I am implementing it called47mileads.

Thank you very much for your help!!!

GK

Is the web.config modified to be ajax enabled?

Is Ajax installed on the webserver? OR Are the ajax extention dll's in the bin folder of the website?

==> You should answer YES to both questions; otherwise you get the error you mentioned above.

Kind regards,
Wim


I started project as AJAX enabled project and I tried both adding dll to bin etc...

I mean dlls not needed in bin since I am not using toolkit (but I added ajaxcontroltoolkit.dll as well). Page where it is happening:http://www.47mileads.com/Account_Login.aspx

Still same error.

Thanks,
GK


It looks like you're referencing the client side framework before it has loaded. This should be exactly what you need: http://encosia.com/2007/08/16/updated-your-webconfig-but-sys-is-still-undefined/


47mileadsdotcom:

I started project as AJAX enabled project and I tried both adding dll to bin etc...

I mean dlls not needed in bin since I am not using toolkit (but I added ajaxcontroltoolkit.dll as well). Page where it is happening:http://www.47mileads.com/Account_Login.aspx

I am not talking about the ajaxcontroltoolkit.dll here.

But I'm talking about the System.web.extentions.dll and the system.web.extentions.design.dll.

Lets say you install Ajax locally. Then those dll's get installed in the GAC (global assembly cache). This way they are accessible to all applications. Therefore they do not need to be included in the BIN of the application.

BUT: Lets say you deploy your application to a webserver. On this webserver, there is NO ajax installed, so NO dll's in the GAC of the webserver. NOW both ajax dll's need to be in the BIN of your application!

Could you please comment on my observations? Regarding the fact that I'm wrong / Or right! :)

Kind regards,
Wim


I installed ajax on the web server as well. Still not working. I also have visual studio on the server installed and I create ajax enabled web application on the server and as soon as I convert it to the web site I get sys undefined.

Thank you very much for your help.

GK


Hi GK,

im not sure but I think I heard this problem before and I think that reinstallation is the only solution (but please try to verify that through articles or threads on the internet)

try reinstalling the asp.net framework, and iis and the ajax framework.

kind regards,
wim


Are you using any URL rewriting on your site?

When I try to load your WebResources and ScriptResources, I get a 404 error. The "Requested URL" makes me wonder about rewriting issues:

Server Error in '/' Application.

The resource cannot be found.

Description:HTTP404. The resource you are looking for (or one of its dependencies)could have been removed, had its name changed, or is temporarilyunavailable. Please review the following URL and make sure that it isspelled correctly.

Requested URL:/.aspx



Yes, I use URL rewriting, but page "account login" does not use URL rewriting.

GK


Hi GK,

But as you said above, even if you create an out-of-the-box ajax enabled website, without extra functionality, even then you get the error no?

This makes me guess something is wrong with the installation ...

Wim.


47mileadsdotcom:

Yes, I use URL rewriting, but page "account login" does not use URL rewriting.

It doesn't itself, but it appears that your rewriter might be interfering with the WebResource and ScriptResource requests embedded in the page (which are used to set up the ASP.NET AJAX functionality on the client).

See if you can globally exclude *.axd requests from rewriting.


I created web application in the same directory as my web site on the server. Error I got was update pannel class reference in the code was not found. I referenced System.Web.Extensions DLL and it started working. When I was developing this project on my local box I did not have to reference System.Web.Extensions DLL since it was already referenced in my web.config. AJAX was installed on my server but web extensions assembly was not accessible from web.config. All you have to do is reference System.Web.Extensions in your references before you deploy your project.

Thank you very much for your help!!!


GK