|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Ajax without Javascript ... don't believe it ... it's just "marketing" (haha). Another understanding would be "keep Javascript simple"... unless you have no choice. The best productivity and results are based on understanding. Ajax and web applications provide great advantages with understanding. BackgroundI started Ajaxion to learn Ajax and I finished by using it to enhance a web page in an old web application, under maintenance. Many thanks to my good colleague, Marius Francu, that supported the first "real world" usage of Ajaxion. The idea here is simple: there is an Ajaxion Javascript layer between the hosting page in the browser and the web server. The Ajaxion Javascript layer defines Ajaxion events enclosing Ajax calls to the web server. The web server runs some C# code (Java coming soon) to consume the Ajaxion events and their Ajax calls. The Ajaxion Javascript layer uses the object XMLHttpRequest to make HTTP calls to the web server. These calls are nearly the same The meaning of Ajaxion is to build further Ajax-enabled controls, more than are currently used. Ajaxion is simple so it can be controlled / customized easily based on what someone could need, e.g. changes in the event monitoring, after that it can be used for specific controls. Using the codeTo use the code just download the sample that is appropriate for your version of .NET:
Further register the "AjaxionTest" web application into IIS, e.g. like this:
Once you have AjaxionTest on your IIS you can take advantage on the great debug power of Visual Studio. A short guide for the codeAjaxion relies in:
How to get an Ajax enabled HTML element by using AjaxionRegister the Ajaxion Javascripts to be used in the host page, e.g. see head of Default.aspx. Choose a HTML element's event to trigger the Ajaxion events: onclick="ajaxion.Call('POST','AjaxCallbackWs.asmx/GetImageUrl',
'imageUrl', GetImageUrl);"
// or e.g. set the HTML event from the C# class of the host page
// (be careful, both methods are used):
btnAjaxWsGetImgUrl.Attributes.Add("onClick",
"ajaxion.Call('POST','AjaxCallbackWs.asmx/GetImageUrl',
'imageUrl', GetImageUrl);");
Register the Ajaxion event (e.g. "imageUrl") and the callback function (e.g. "GetImageUrl") in the host page specific script (e.g. DefaultAspx_AjaxionEvents.js) // Register Ajaxion event "imageUrl"
function GetEventParameters(eventId)
{
ajaxion.ShowStatus('status', 'Processing...', 'coral');
ajaxion.ShowStatusGif('statusGif', 'images/processing.gif');
var parameters = '';
switch (eventId)
{
...
case 'imageUrl' :
ajaxion.SetEventMonior('imageUrl', '');
parameters = window.document.getElementById('dropDown').value;
break;
...
}
return parameters;
}
// Ajaxion event "imageUrl" callback function.
// This updates the host page after the Ajax call for the
// Ajaxion event was consumed.
function GetImageUrl()
{
if (ajaxion.request.readyState == 4
|| ajaxion.request.readyState == 'complete')
{
window.document.getElementById('image').src =
ajaxion.request.responseText;
window.document.getElementById('image').title =
ajaxion.GetParameters();
EndAjaxionEvent();
}
}
And, last but not least, the C# code to consume the "imageUrl" Ajaxion event (in this example there is a web service method): [WebMethod]
public void GetImageUrl()
{
Thread.Sleep(700); // Only to see status change, ajax effect
try
{
string eventId;
if (this.Context.Request.QueryString["imageUrl"] == null)
eventId = "imageUrlIe6";
else
eventId = "imageUrl";
AjaxEventConsummer callback = new AjaxEventConsummer(this.Context,
eventId, "image/GIF");
callback.ConsumeEvent("images/" + callback.Parameters);
}
catch (System.Threading.ThreadAbortException)
{}
catch (Exception ex)
{
FileLog.LogLine("\nException: " + ex.Message +
"\nTrace: " + ex.StackTrace);
}
}
Points of InterestThe functionality demonstrated is (in the order it appears):
Hope this helps.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||