|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThis is a custom web control for implementing AJAX in a Web Form. Now this has been done a couple of times I realize but most of these implementations I think would be difficult to implement in the production code. I didn’t understand why, for example, the JavaScript files would be added to my web site at runtime. I also didn’t understand why I needed to add attributes to my server sided function I intended to call from the client. I looked at Atlas and while I’m sure it’s a great way to do AJAX, I didn’t like the fact that I had to learn a bunch of script syntax and that I had to add so many links to the JavaScript files. It seemed messy to me for some reason. My solutionMy goal was to create a control that I could drop on any form in multiple assemblies. I also wanted to minimize what developers had to know in order to use the control. The control should be able to call either a web service and/or a class in the Web Forms assembly and use the same function signature as the server sided function. The developer would set the Jax1.Callback = "MyJaxTest.WebForm1"
Jax1.WebServiceURL = "http://localhost/myJaxTest/Math.asmx"
My solution is to create the JavaScript functions to call both the web service and the Calling web servicesCalling the web service is done by calling the WSDL of the web service. I then use XSL to transform the WSDL into something easier to use. From that I create the JavaScript to call each function of the web service. I end up making the function stubs for asynchronous calls but they are not supported in this version of the control. All that the developer needs to do is call the web service with the same function signature: function cmdWSTest_onclick()
{
alert(Multiply(2,3));
}
Calling server classesCalling classes in the Web Form assembly is a bit trickier. I use reflection to create the JavaScript stubs for the web page. This means I don’t have to apply attributes to the function signatures. If the method is About AJAXOn a note about AJAX, calling server sided code has a lot of promise. We did this years ago in ASP code. ASP.NET is so geared to doing things on the server that it sacrifices user experience for speed of development. The real challenge for AJAX application is not getting the information from the server as this control makes this pretty easy. The real issue is how you use it on the client. For example, you can bring back a bunch of XML from a
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||