Update of /cvsroot/magicajax/magicajax/Core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12381/Core
Modified Files:
MagicAjaxModule.cs
Log Message:
Fixed Page.Request/Page.Response not being valid during an AjaxCall.
Replaced GetControlHash method by Page.GetTypeHashCode.
Index: MagicAjaxModule.cs
===================================================================
RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** MagicAjaxModule.cs 15 Nov 2005 14:07:31 -0000 1.8
--- MagicAjaxModule.cs 16 Nov 2005 08:08:58 -0000 1.9
***************
*** 396,403 ****
{
case PageStoreMode.Session:
! return String.Format("__AJAX_{0}_{1}", page.Request.FilePath, GetControlHash(page));
case PageStoreMode.Cache:
! return String.Format("__AJAX_{0}_{1}_{2}", _context.Session.SessionID, page.Request.FilePath, GetControlHash(page));
default:
--- 396,403 ----
{
case PageStoreMode.Session:
! return String.Format("__AJAX_{0}_{1}", page.Request.FilePath, page.GetTypeHashCode());
case PageStoreMode.Cache:
! return String.Format("__AJAX_{0}_{1}_{2}", _context.Session.SessionID, page.Request.FilePath, page.GetTypeHashCode());
default:
***************
*** 406,421 ****
}
- protected virtual int GetControlHash(Control control)
- {
- int childHash = -1;
- for (int i=0; i < control.Controls.Count; i++)
- childHash ^= GetControlHash(control.Controls[i]);
- childHash = ~childHash;
-
- int conHash = String.Format("{0}_{1}", control.GetType(), control.ID).GetHashCode();
-
- return conHash ^ childHash;
- }
-
/// <summary>
/// Handles the AcquireRequestState event of the HttpApplication
--- 406,409 ----
***************
*** 464,467 ****
--- 452,457 ----
if ( PageStoreMode.NoStore == _config.PageStore.Mode )
{
+ // The page is not stored
+
if ( _isAjaxCall )
{
***************
*** 529,533 ****
{
// PostBack. Will replace the recreated controls with the stored ones
! requestPage.Init += new EventHandler(RequestedPage_Init);
}
else
--- 519,523 ----
{
// PostBack. Will replace the recreated controls with the stored ones
! requestPage.Load += new EventHandler(RequestedPage_Init);
}
else
***************
*** 550,553 ****
--- 540,553 ----
ProcessAjaxCall(_currentPageInfo.Page);
+ /*
+ try
+ {
+ ProcessAjaxCall(_currentPageInfo.Page);
+ }
+ catch(Exception exc)
+ {
+ string hhh = exc.Message;
+ int uu=5;
+ }*/
_currentPageInfo.AjaxCallsCount++;
***************
*** 561,569 ****
protected virtual void RequestedPage_Init(object sender, EventArgs e)
{
! Page requestPage = (Page) sender;
! System.Web.UI.HtmlControls.HtmlForm storedForm = (System.Web.UI.HtmlControls.HtmlForm) _currentPageInfo.Page.Controls[1];
! // Remove the HtmlForm of requested page
! requestPage.Controls.RemoveAt (1);
! requestPage.Controls.AddAt (1, storedForm);
}
--- 561,566 ----
protected virtual void RequestedPage_Init(object sender, EventArgs e)
{
! // TODO: Replace the controls of AjaxControls from requestedPage with controls from stored page.
! return;
}
***************
*** 585,595 ****
// There was a Response.Redirect or Server.Transfer during AjaxCall
! HttpApplication application = (HttpApplication) sender;
! HttpResponse response = application.Context.Response;
!
! if (response.RedirectLocation != null)
{
// Handle Response.Redirect
! AjaxCallHelper.Redirect (response.RedirectLocation);
}
else
--- 582,589 ----
// There was a Response.Redirect or Server.Transfer during AjaxCall
! if (_response.RedirectLocation != null)
{
// Handle Response.Redirect
! AjaxCallHelper.Redirect (_response.RedirectLocation);
}
else
***************
*** 610,613 ****
--- 604,610 ----
protected virtual void ProcessAjaxCall(Page page)
{
+ // Required for Page.Request/Page.Response to be valid
+ CallPrivateMethod (page, typeof(Page), "SetIntrinsics", _context);
+
ReadOnlyArrayList postDataChangedControls;
postDataChangedControls = new ReadOnlyArrayList(LoadFormDataOnChildren(page));
***************
*** 812,815 ****
--- 809,825 ----
return list;
}
+
+ /// <summary>
+ /// Call a private method from the given object.
+ /// </summary>
+ /// <param name="instance"></param>
+ /// <param name="type"></param>
+ /// <param name="methodName"></param>
+ /// <param name="parameters"></param>
+ /// <returns></returns>
+ protected object CallPrivateMethod(object instance, Type type, string methodName, params object[] parameters)
+ {
+ return type.GetMethod(methodName, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(instance, parameters);
+ }
#endregion
|