Murano Software Inc .
description
Transcript of Murano Software Inc .
Murano Software Inc.
AJAX & ASP.NET
Коренков Максим
Classic Web application
AJAX approach
AJAX approach benefits
Более быстрый отклик на действия Загрузка по требованию Уменьшается загрузка канала
AJAX & ASP.NET
Объект XmlHttpRequest ICallbackEventHandler ASP.NET AJAX
From scratch. XmlHttpRequest IE 5.0 ActiveX “Microsoft.XmlHttp” Other browsers native implementation Частично формализован в “The DOM Level
3 Load and Save Specification”
From scratch. XmlHttpRequestfunction createXMLHttpRequest() {
var xmlHttp;if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest(); }else{
xmlHttp = null;}return xmlHttp;
}
From scratch. XmlHttpRequestfunction makeRequest() {
createXMLHttpRequest(); xmlHttp.onreadystatechange = onAsyncResponse; xmlHttp.open("GET", “HandlePage.aspx", true); xmlHttp.send(null);
} function onAsyncResponse() {
if(xmlHttp.readyState == 4 && xmlHttp.status == 200) //complete && OK{
alert("Response: " + xmlHttp.responseText); }
}
XmlHttpRequest problems
Кэширование GET-запроса (напр., IE)
req.open( "GET", “mypage.aspx?rand=" + Math.random()); C# Response
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetNoServerCaching();
Response.Cache.SetExpires(DateTime.Now);
ICallbackEventHandler
Обычная последовательность Page events Возврат данных до Render
ICallbackEventHandler
public interface ICallbackEventHandler
{
string GetCallbackResult();
void RaiseCallbackEvent(string eArg);
}
ICallbackEventHandler problems IE only