PageMethods - Nightmare!

by Sumant 27. August 2008 19:52

Can't believe such a cool method can actually become such a big pain!

I have been using PageMethods a lot and have experienced that sometime the call simply doesn't work. I used to clean the solution, rebuild, clear cache etc, but never tried to find the real reason behind it. Somehow they have been fair enough with me to perform when needed.

Today again I got stuck in a similar scenario and things started getting worse. After wasting a lot of time, a little google lead me to this article - posted around an year ago. I can't believe it's really normal to get such silly errors (more so because they are bundled with the product and not because of my silly code) and I used to think PageMethods hate only me. ;)

Well if you encounter this 'PageMethods - Missing or Not Behaving' issue, I highly recommend reading the article and all the comments which has a lot of different experiences recorded. If you have anything to add, to help us, please leave your comments here.

Another issue with PageMethods that I have recently encountered and still remains unresolved is - unnecessary postback after successful execution callback. I have a webpage in one of the applications which calls a PageMethod to validate some input. On successful execution, the callback method is called which displays the result in a label on the same page. The code works fine on my machine, Win XP, tested with IE 7.0 and FF 3.0, but the same page behaves differently on my friends machine, Win Vista, on IE 7.0. There it does am unnecessary post back after changing the label to result from callback method. I tried everything from putting "return false;" to a lot of different tricks, but no luck. Will debug it further, a little later, and will update here about the findings.

Hoping to find more about the mystery behind PageMethod's abnormal behavior.

Share   
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags: ,

.NET | AJAX | ASP.NET | Web Development

Upgrading existing ASP.NET project to AJAX Enabled Web Application

by Sumant 19. October 2007 22:37

If you want to convert existing ASP.net web application to AJAX Enabled web application then it is as easy as just updating your existing project's web.config file, other than adding a new reference. But you need to take care of certain things otherwise this simple change might give you a tough time before you can actually start using new ASP.NET AJAX features in the existing application.

I am assuming that you have already installed ASP.NET AJAX 1.0 extension.

Following these simple steps first to add ASP.NET AJAX power to your application -

  • Open your existing application and add a new reference to 'System.Web.Extensions' assembly.
     
  • Now create a new ASP.NET AJAX enabled web application (we will use this new project to copy new settings to existing project).
     
  • Compare new application's web.config with your existing application's web.config.
     
  • Copy all new settings that you see in new project's web.config to existing application's web.config.

Now take care of certain things which might actually make your application behave weirdly while using ASP.NET AJAX features -

  • It is very important that if your existing application is still using Legacy XHTML conformance mode, then remove this declaration from your web.config -

    '<xhtmlConformance mode ="Legacy"/>'
     
  • If your application pages are still using non xhtml or old html DOCTYPE declaration then change it to use XHTML 1.0 (at least transitional) by using this declaration instead -

    "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">"
     
  • If after doing these changes, you face some issue with intellisense in Visual Studio then you will have to change the Tag Prefix for "System.Web.Extensions" assembly from 'asp' to anything else. For this locate this line in your application's web.config -

    "<add tagPrefix="ajax" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>"

     and replace the tagPrefix="asp" with tagPrefix="ajax" (or anything of your choice).

    Now instead of using <asp:ScriptManager> or <asp:UpdatePanel>, you will have to use this new prefix (like <ajax:ScriptManager>). But this hack will get back your Visual Studio's intellisense working.

If after all this you are still unable to upgrade your existing ASP.NET application to ASP.NET AJAX 1.0, please feel free to write to me. :)

Share   
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

ASP.NET | AJAX | Web Development | .NET

© 2008 Sumant Dubey

About this blog

Absolutely technical! The posts are about concepts, tricks, articles and links on technical subjects / problems which are not very obvious to understand / resolve. Purpose is to have this as the first-aid in the time of need.

Disclaimer

The opinions expressed on this website are my own personal opinions and do not represent my employer's view in anyway.