Update of /cvsroot/magicajax/magicajax/Core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5437/Core
Modified Files:
AjaxCallHelper.cs MagicAjaxContext.cs MagicAjaxModule.cs
Log Message:
--Fixed the javascript errors that occured when the browser was not supported. Added a 'IsBrowserSupported' check before any MagicAjax specific additions on the page.
--An exception is thrown if MagicAjaxModule is not included in the HttpModules of web.config and the code tries to access MagicAjaxContext.Current
. MagicAjaxContext is being created by MagicAjaxModule at the BeginRequest event.
--Added 'MagicAjaxContext' protected property in AjaxControl, AjaxPage and AjaxUserControl classes and use it in the Ajax controls instead of MagicAjaxContext.Current
Index: AjaxCallHelper.cs
===================================================================
RCS file: /cvsroot/magicajax/magicajax/Core/AjaxCallHelper.cs,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** AjaxCallHelper.cs 27 Nov 2005 17:28:26 -0000 1.11
--- AjaxCallHelper.cs 30 Nov 2005 12:22:29 -0000 1.12
***************
*** 217,223 ****
if (milliSeconds > 0)
{
! if (MagicAjaxContext.Current.IsAjaxCall)
Write (String.Format("AJAXCbo.SetIntervalForAjaxCall({0});", milliSeconds));
! else
{
//EnableAjaxOnPage();
--- 217,225 ----
if (milliSeconds > 0)
{
! if ( MagicAjaxContext.Current.IsAjaxCall )
! {
Write (String.Format("AJAXCbo.SetIntervalForAjaxCall({0});", milliSeconds));
! }
! else if ( MagicAjaxContext.Current.IsBrowserSupported )
{
//EnableAjaxOnPage();
Index: MagicAjaxContext.cs
===================================================================
RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxContext.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** MagicAjaxContext.cs 27 Nov 2005 17:28:26 -0000 1.6
--- MagicAjaxContext.cs 30 Nov 2005 12:22:29 -0000 1.7
***************
*** 32,35 ****
--- 32,37 ----
public class MagicAjaxContext
{
+ internal static readonly string ContextKey = "__MAGICAJAXCONTEXT";
+
#region Private properties
private bool _isAjaxCall = false;
***************
*** 164,168 ****
#region Public Ctor
! public MagicAjaxContext()
{
// Load configuration from web.config
--- 166,170 ----
#region Public Ctor
! internal MagicAjaxContext()
{
// Load configuration from web.config
***************
*** 208,217 ****
{
// get the portal context for the current HTTP request
! magicAjaxContext = (MagicAjaxContext)HttpContext.Current.Items["__MAGICAJAXCONTEXT"];
if ( magicAjaxContext == null )
{
! // create a new context and add it to the items collection for later retrieval
! magicAjaxContext = new MagicAjaxContext();
! HttpContext.Current.Items.Add("__MAGICAJAXCONTEXT", magicAjaxContext);
}
}
--- 210,218 ----
{
// get the portal context for the current HTTP request
! magicAjaxContext = (MagicAjaxContext)HttpContext.Current.Items[ContextKey];
if ( magicAjaxContext == null )
{
! // MagicAjaxModule is not loaded
! throw new MagicAjaxException("The MagicAjax HttpModule is not included in web.config. Add [<httpModules><add name=\"MagicAjax\" type=\"MagicAjax.MagicAjaxModule, MagicAjax\" /></httpModules>] inside the <system.web> section.");
}
}
Index: MagicAjaxModule.cs
===================================================================
RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** MagicAjaxModule.cs 25 Nov 2005 20:45:47 -0000 1.35
--- MagicAjaxModule.cs 30 Nov 2005 12:22:29 -0000 1.36
***************
*** 396,401 ****
_request = context.Request;
_response = context.Response;
- _magicAjaxContext = MagicAjaxContext.Current;
// Check if the request is for the embedded AjaxCallObject.js script
--- 396,404 ----
_request = context.Request;
_response = context.Response;
+ // Create a new context and add it to the items collection for later retrieval
+ // by MagicAjaxContext.Current
+ _magicAjaxContext = new MagicAjaxContext();
+ HttpContext.Current.Items.Add(MagicAjaxContext.ContextKey, _magicAjaxContext);
// Check if the request is for the embedded AjaxCallObject.js script
|