Monday, March 26, 2012

ASP.Net Ajax compatibility

I need to write an application running on the internet. So I suggested to write it using ASP.net Ajax. But I need to know how is the compatibility of ASP.Net Ajax with other browsers and different versions?Which resources works on a specific browser and which doesn't work.Basically, I need my application working on IE 5+. Will Ajax run on this scenario?Ajax is built on pieces that are available in most recent browsers. I'm pretty sure IE 5.0 is included in the list. If you use Atlas, which is the ASP.Net implementation of programming with Ajax, you'll get browser compatability and their list of supported browsers should be availablehere.

ASP.NET AJAX Callbacks in Server Control

I have been heavy into doing AJAX control development. The one thing that I can't seem to find any information about is callbacks in an ASP.NET AJAX Server Control. In terms of "callbacks" I've found:

ICallbackEventHandler - Pre- ASP.NET AJAX technology, although is used in AJAX controls (e.g. the AJAX Control Toolkit's Rating control)

Web Services - Is an issue since the service isn't part of the control. I don't want to have to include an asmx page in an app that uses my control; plus it really doesn't make sense

Am I missing something? Is ICallbackEventHandler the correct way to handle callbacks in an AJAX control? Is there something new in .NET 3.5 that will take it's place?

-Damien

hello.

well, i think there really isn't anything new here.if you're just trying to run some server logic associated with a control, then ICallbackEventhandler is the way to go.

ASP.NET AJAX Calendar Extender - set value programatically

How to set the calendar extender date programatically?Try CalendarBehavior's set_selectedDate, set_visibleDate, or set_todaysDate methods.

ASP.NET AJAX Breaks with Custom Url Rewriting

I am having two related issues with ASP.NET AJAX. I used the AtlasToolkit PopupControlExtender to create a very simple Popup Calendar. I have created a custom HtmlTextWriter and HttpModule to rewrite incoming url's based on incoming path. So essiently if I nav /This/Page/Does/Not/Exist.aspx, the module will check the file system to see if that page physically exists, and if not then check the database for the corresponding PageId and rewrite it ~/Page.aspx?PageId=DoesNotExistId. Then I have overriden Render and written a custom HtmlTextWriter that looks for <form action=""> and sets that attribute equal to the fully qualified url requested.

The problem goes like this. Anytime before I do any ASP.NET UI events, everything is fine. After an ASP.NET AJAX UI event the Form.Action attribute reads Page.aspx?pageid=blah. Is there anyway to override this behavior?

Thank you,

Jason Lind

I'm like 99% sure this a bug. The line of js that causes this most of the time will do nothing, except when you're rewriting and then it breaks your application

See lines 1061 through 1069 in MicrosoftAjaxWebForms.js (the debug version) pasted here for your convienance:

if (handler) { handler(this,this._getPageLoadingEventArgs()); }if (formActionNode) {this._form.action = formActionNode.content;this._form._initialAction =this._form.action; }

Basically on any ASP.NET AJAX ui event the form.action is being reset to the response. I can see no reason for doing this, for as far as I can tell there is no information being added to the action. My guess is at some version in development this was the case and that approach was later dropped and this code never was refactored.

Can someone on the ASP.NET AJAX team please confirm this and assure me that in some later release this won't be an issue, maybe even commentif (formActionNode) {this._form.action = formActionNode.content;this._form._initialAction =this._form.action; } out and issue me a hot fix?

Thank you,

Jason Lind

Lead Software Engineer / Triton Tek


<script type="text/javascript">
Type.registerNamespace("ScriptLibrary");
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(pageLoaded);
function pageLoaded(sender, args) {
document.forms[0].action = requestUrl;
document.forms[0]._initialAction = requestUrl;
}
var requestUrl = "";
function body_onload()
{
requestUrl = document.forms[0].action;
}
</script>

Still should be fixed.


Kinda hard to say what's going on here, but first here's why we do that form action stuff. When modules such as session and authentication rewrite the URL in their cookieless modes, we need to reset the form action to be whatever the rewritten URL is. We do it in a manner similar to what you're doing by checking the form's action and grabbing whatever it has.

However, in your case it sounds like you're using a customwriter to do the work, which might be the problem in this scenario. Instead you should override the form's rendering functionality and just change the action there. Then Atlas will pick it up and use whatever you set. Here are a couple of articles on the subject:

General URL rewriting:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/urlrewriting.asp (but, ignore the part where it says to write an actionless URL!)
Atlas URL rewriting:http://geekswithblogs.net/lazydeveloper/archive/2006/08/17/88247.aspx (this is the important part)

Thanks,

Eilon

ASP.Net Ajax Book Reference Suggestions Needed...

Hi everybody,

Can you guys suggest some very good books using AJAX and Atlas in ASP.Net 2.0 that are now available in the market? Please specify complete Book Title and Authors and also ISBN if possible. I need book that covers if possible all aspects of Ajax with ASP.Net 2.0 that is in beginner to Advanced level, if there is one. Can you arrange them in order best reference to least and why? I need reference using ajax because of data transfer performance issues. Thanks in advanced.

den2005Smile

bump.. I am also very interesting on this topic.

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 Beta 2 Bug

I have a popup window in a web project that on postback executes the following startup JavaScript:

window.opener.document.getElementById('rptrOtherCrit_ctl01_PTSValList1_hdnValues').value ='NJ';window.opener.__doPostBack('rptrOtherCrit$ctl01$PTSValList1$hdnValues','')window.opener.focus();window.close();

The hidden control in the opening page that is being modified is within an <asp:UpdatePanel> control. Everything works fine when using IE 6 but, when using Firefox 2.0 the following error appears in the Error Console:

Error: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://localhost/TaxBrowser/ScriptResource.axd?d=rrMPh95m1EXHDVTP53sdlY7yEQVgCg7PqciEiGs1HCx_e6TnjvyveNwrB2X38b1_rlFCHP1MhbU0L_WYwgrZDpG_PF1uwTqLpZqVE5wb1XLd2paC8td9zt_W4KlqoZhrtCCwf7Z_N-6whUkZJdtjEe1ZeMEM-Pqb3wvBBXghujU1&t=633008283654152282 :: Sys$Net$XMLHttpExecutor$get_statusCode :: line 3509" data: no]
Source File: http://localhost/TaxBrowser/ScriptResource.axd?d=rrMPh95m1EXHDVTP53sdlY7yEQVgCg7PqciEiGs1HCx_e6TnjvyveNwrB2X38b1_rlFCHP1MhbU0L_WYwgrZDpG_PF1uwTqLpZqVE5wb1XLd2paC8td9zt_W4KlqoZhrtCCwf7Z_N-6whUkZJdtjEe1ZeMEM-Pqb3wvBBXghujU1&t=633008283654152282
Line: 3509


Certainly looks like a bug to me.

Try to test?it?in?IE?7.0,Opera,Escape?or?Safari?and?check?if?it?gets?the?same?error.Maybe?the?error?message?is?caused?by?
FireFox, not?Ajax?bug. Besides,can you post some codes here?This maybe?gives?us?to?fix?the?problem.
Try?to?debug?your?codes?and?fix?which?code?lines?cause?the?error?message.

I'm getting the same error (in firefox) just trying the sample at:

http://ajax.asp.net/docs/ViewSample.aspx?sref=Sys.Net.PageMethod%23PageMethod.aspx but not in IE 6. I'll try updating firefox


You need to add "[Microsoft.Web.Script.Services.ScriptService]" in front of the web service class in Ajax Beta 2.It is said this is a known bug in Ajax Beta 2.Try to add it and test your codes in IE,FireFox,Opera and Safari.Please let me know the testing results.