I have recently jumped on the AJAX bandwagon and am frantically trying to AJAX enable all my web pages through the use of asynchronous partial-page updates.
A typical design pattern of an ASP.NET AJAX application involves it consuming web services directly from the client without requiring postbacks to the web server. Not only do postbacks slow down an application, but they also complicate the application design, implementation, and deployment.
AJAX is so addictive and such a compelling technology that once you have gotten the hang of it, it is hard to refrain from using it.
However, all said and done, there are some pitfalls that one ought to be aware of.
This blog post is certainly not intended for what AJAX can or can’t do, but if you are looking to convert your web page and make them AJAX enabled, there are a few things you have got to keep in mind just in case you are stuck.
I had a web page with input controls on a panel all of which were wired to the validator controls. In addition, I also had a FileUpload control.
Prior to AJAX enabling the web page, everything was fine and dandy, but the minute I wrapped the asp panel in an Update Panel, everything worked but the FileUpload. In that, the control (FileUpload) did not detect the file name and returned an empty string when checking for FileUpload.HasFile.
The solution to the problem was not difficult either.
In the markup, essentially all that was missing was the PostBackTrigger with the ControlID="btnSubmit".
So essentially, all that is happening now is that we are forcing a post back on the click event of the button while everything else happens asynchronously using the Update Panel. So, when the user presses the button, the page gets refreshed and filename is detected.