You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(204) |
Dec
(147) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(52) |
Feb
(33) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Dion O. <dol...@us...> - 2005-11-16 22:54:39
|
Update of /cvsroot/magicajax/magicajax/Core/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20348/magicajax/Core/UI Modified Files: RenderedByScriptControl.cs Log Message: Firefox keeps the form data of a page when doing a page reload or using the back/forward button. However, the 'RenderedByScriptControls' will disappear after a reload. To redraw these controls on the page, we will force a callback from the client's window.onload when the value of hidden field '__RBSCONTROLSEXIST' equals '1'. This hidden field is set to '1' whenever a callback is made. On first page rendering, the value of this hidden field is '0'. Internet Explorer always resets all form data on a page refresh (also the hidden field '__RBSCONTROLSEXIST'), so for IE no extra callback will be forced. Index: RenderedByScriptControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/RenderedByScriptControl.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RenderedByScriptControl.cs 14 Nov 2005 18:50:43 -0000 1.2 --- RenderedByScriptControl.cs 16 Nov 2005 22:54:31 -0000 1.3 *************** *** 173,189 **** protected override void OnPreRender(EventArgs e) { ! if ( ! IsChildOfRenderedByScriptControl(this) ) { ! // Firefox, when performing a refresh, loads the page but keeps any INPUT ! // field values. Thus, the html of a RenderedByScriptControl is restored ! // as if the page was loaded because of the browser's "Back Button". ! // To resolve this, the name of the storing fields is different for ! // each page request. ! string hiddenStore = this.ClientID + "$RBS_Store" + DateTime.Now.Ticks; ! Page.RegisterHiddenField(hiddenStore, null); ! Page.RegisterArrayDeclaration("RBS_Controls", String.Format("document.all[\"{0}$RBS_Holder\"]", this.ClientID)); ! Page.RegisterArrayDeclaration("RBS_Controls_Store", String.Format("document.all[\"{0}\"]", hiddenStore)); } - base.OnPreRender (e); } --- 173,204 ---- protected override void OnPreRender(EventArgs e) { ! if (!IsChildOfRenderedByScriptControl(this)) { ! if (IsPageNoStoreMode) ! { ! // Firefox keeps the form data of a page when doing a page reload or using ! // the back/forward button. ! // However, the 'RenderedByScriptControls' will disappear after a reload. ! // To redraw these controls on the page, we will force a callback from the client's ! // window.onload when the value of hidden field '__RBSCONTROLSEXIST' ! // equals '1'. This hidden field is set to '1' whenever a callback is made. ! // On first page rendering, the value of this hidden field is '0'. ! // Internet Explorer always resets all form data on a page refresh (also the hidden ! // field '__RBSCONTROLSEXIST'), so for IE no extra callback will be forced. ! Page.RegisterHiddenField("__RBSCONTROLSEXIST", "0"); ! } ! else ! { ! // Firefox, when performing a refresh, loads the page but keeps any INPUT ! // field values. Thus, the html of a RenderedByScriptControl is restored ! // as if the page was loaded because of the browser's "Back Button". ! // To resolve this, the name of the storing fields is different for ! // each page request. ! string hiddenStore = this.ClientID + "$RBS_Store" + DateTime.Now.Ticks; ! Page.RegisterHiddenField(hiddenStore, null); ! Page.RegisterArrayDeclaration("RBS_Controls", String.Format("document.all[\"{0}$RBS_Holder\"]", this.ClientID)); ! Page.RegisterArrayDeclaration("RBS_Controls_Store", String.Format("document.all[\"{0}\"]", hiddenStore)); ! } } base.OnPreRender (e); } |
From: Argiris K. <be...@us...> - 2005-11-16 13:39:23
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7305/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Some bug fixes. Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AjaxPanel.cs 15 Nov 2005 13:06:16 -0000 1.7 --- AjaxPanel.cs 16 Nov 2005 13:39:14 -0000 1.8 *************** *** 468,472 **** else { ! ExtendedRenderControl (con, output, litewriter); html = sb.ToString(); --- 468,476 ---- else { ! if ( IsPageNoStoreMode ) ! ExtendedRenderControl (con, output, litewriter); ! else ! ExtendedRenderControl (con, litewriter); ! html = sb.ToString(); |
From: Argiris K. <be...@us...> - 2005-11-16 13:39:23
|
Update of /cvsroot/magicajax/magicajax/CustomControls/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7305/CustomControls/UI/Controls Modified Files: AjaxCascadeTable.cs AjaxTabbedPanel.cs Log Message: Some bug fixes. Index: AjaxTabbedPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/CustomControls/UI/Controls/AjaxTabbedPanel.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AjaxTabbedPanel.cs 11 Nov 2005 06:17:49 -0000 1.1 --- AjaxTabbedPanel.cs 16 Nov 2005 13:39:14 -0000 1.2 *************** *** 32,36 **** /// Summary description for AjaxCascadeTable. /// </summary> ! [Designer("MagicAjax.UI.Design.AjaxTabbedPanelDesigner, MagicAjax")] public class AjaxTabbedPanel : AjaxLinkedPanelListControl { --- 32,36 ---- /// Summary description for AjaxCascadeTable. /// </summary> ! [Designer("MagicAjax.UI.Design.AjaxTabbedPanelDesigner, MagicAjax.CustomControls")] public class AjaxTabbedPanel : AjaxLinkedPanelListControl { Index: AjaxCascadeTable.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/CustomControls/UI/Controls/AjaxCascadeTable.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AjaxCascadeTable.cs 11 Nov 2005 06:17:49 -0000 1.1 --- AjaxCascadeTable.cs 16 Nov 2005 13:39:14 -0000 1.2 *************** *** 32,36 **** /// Summary description for AjaxCascadeTable. /// </summary> ! [Designer("MagicAjax.UI.Design.AjaxCascadeTableDesigner, MagicAjax")] public class AjaxCascadeTable : AjaxLinkedPanelListControl { --- 32,36 ---- /// Summary description for AjaxCascadeTable. /// </summary> ! [Designer("MagicAjax.UI.Design.AjaxCascadeTableDesigner, MagicAjax.CustomControls")] public class AjaxCascadeTable : AjaxLinkedPanelListControl { |
From: Argiris K. <be...@us...> - 2005-11-16 08:09:06
|
Update of /cvsroot/magicajax/magicajax/Core/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12381/Core/UI Modified Files: AjaxPage.cs AjaxUserControl.cs Log Message: Fixed Page.Request/Page.Response not being valid during an AjaxCall. Replaced GetControlHash method by Page.GetTypeHashCode. Index: AjaxUserControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxUserControl.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AjaxUserControl.cs 14 Nov 2005 18:50:43 -0000 1.2 --- AjaxUserControl.cs 16 Nov 2005 08:08:58 -0000 1.3 *************** *** 26,41 **** { /// <summary> ! /// Includes the AjaxCall event, Context, Request and Response, for convenience. /// </summary> /// <remarks> ! /// You can implement the IAjaxCallEventHandler on your usercontrol to handle the ! /// AjaxCall event, and use the HttpContext.Current, AjaxCallHelper.Request and ! /// AjaxCallHelper.Response properties. ! /// ! /// You cannot use the Context, Request and Response of the System.Web.UI.UserControl ! /// because, during an AjaxCall, the Context of the page is invalid. If you don't want ! /// to replace the UserControl.Request and UserControl.Response from your code for ! /// AjaxCallHelper.Request and AjaxCallHelper.Response, and your usercontrol is inherited ! /// from System.Web.UI.UserControl, you can use AjaxUserControl for convenience. /// </remarks> public class AjaxUserControl : System.Web.UI.UserControl, IAjaxCallEventHandler --- 26,34 ---- { /// <summary> ! /// Includes the AjaxCall event. /// </summary> /// <remarks> ! /// Inheriting from AjaxUserControls is not required, you can implement the ! /// IAjaxCallEventHandler on your usercontrol to handle the AjaxCall event. /// </remarks> public class AjaxUserControl : System.Web.UI.UserControl, IAjaxCallEventHandler *************** *** 47,72 **** /// <summary> - /// The base UserControl Request property doesn't work during an AjaxCall. Use this instead. - /// </summary> - public new HttpRequest Request - { - get - { - return Context.Request; - } - } - - /// <summary> - /// The base UserControl Response property doesn't work during an AjaxCall. Use this instead. - /// </summary> - public new HttpResponse Response - { - get - { - return Context.Response; - } - } - - /// <summary> /// Raises the AjaxCall event. /// </summary> --- 40,43 ---- *************** *** 79,90 **** } - protected override HttpContext Context - { - get - { - return HttpContext.Current; - } - } - protected virtual void OnAjaxCall(EventArgs e) { --- 50,53 ---- Index: AjaxPage.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxPage.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AjaxPage.cs 14 Nov 2005 18:50:43 -0000 1.2 --- AjaxPage.cs 16 Nov 2005 08:08:58 -0000 1.3 *************** *** 26,42 **** { /// <summary> ! /// Includes the AjaxCall event, Context, Request and Response, for convenience. /// </summary> /// <remarks> /// Inhering from AjaxPage is not required to apply AJAX on your pages. You can ! /// implement the IAjaxCallEventHandler on your page to handle the AjaxCall event, and ! /// use the HttpContext.Current, AjaxCallHelper.Request and AjaxCallHelper.Response ! /// properties. ! /// ! /// You cannot use the Context, Request and Response of the System.Web.UI.Page ! /// because, during an AjaxCall, the Context of the page is invalid. If you don't want ! /// to replace the Page.Request and Page.Response from your code for ! /// AjaxCallHelper.Request and AjaxCallHelper.Response, and your page is inherited ! /// from System.Web.UI.Page, you can use AjaxPage for convenience. /// </remarks> public class AjaxPage : System.Web.UI.Page, IAjaxCallEventHandler --- 26,34 ---- { /// <summary> ! /// Includes the AjaxCall event. /// </summary> /// <remarks> /// Inhering from AjaxPage is not required to apply AJAX on your pages. You can ! /// implement the IAjaxCallEventHandler on your page to handle the AjaxCall event. /// </remarks> public class AjaxPage : System.Web.UI.Page, IAjaxCallEventHandler *************** *** 48,73 **** /// <summary> - /// The base Page Request property doesn't work during an AjaxCall. Use this instead. - /// </summary> - public new HttpRequest Request - { - get - { - return Context.Request; - } - } - - /// <summary> - /// The base Page Response property doesn't work during an AjaxCall. Use this instead. - /// </summary> - public new HttpResponse Response - { - get - { - return Context.Response; - } - } - - /// <summary> /// Raises the AjaxCall event. /// </summary> --- 40,43 ---- *************** *** 80,91 **** } - protected override HttpContext Context - { - get - { - return HttpContext.Current; - } - } - protected virtual void OnAjaxCall(EventArgs e) { --- 50,53 ---- |
From: Argiris K. <be...@us...> - 2005-11-16 08:09:06
|
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 |
From: Dion O. <dol...@us...> - 2005-11-15 14:07:52
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12449/magicajax/Core/script Added Files: WebParts.js Log Message: Added code for using embedded 'WebParts.js' file inside ASP.NET 2.0 WebPart pages. --- NEW FILE: WebParts.js --- // Script to 'reset' current webpartmanager // Note: only used for ASP.NET 2.0 WebPart framework function WebPartManager_Cleanup() { if (__wpm != null && __wpm.zones != null) { //loop zones for (var i = 0; i < __wpm.zones.length; i++) { var zone = __wpm.zones[i]; //detach current zone events if (zone.webPartTable != null) { zone.webPartTable.detachEvent('ondragenter', Zone_OnDragEnter); zone.webPartTable.detachEvent('ondrop', Zone_OnDrop); zone.webPartTable.detachEvent('ondrop', Zone_OnDrop); } //loop webparts of current zone if (zone.webParts != null) { for (var j = 0; j < zone.webParts.length; j++) { var webpart = zone.webParts[j]; //detach current webpart events webpart.webPartElement.detachEvent('ondragstart', WebPart_OnDragStart); webpart.webPartElement.detachEvent('ondrag', WebPart_OnDrag); webpart.webPartElement.detachEvent('ondragend', WebPart_OnDragEnd); } } //dispose zone __wpm.zones[i].Dispose(); } //reset zone array in webpartmanager __wpm.zones = new Array(); } } |
From: Dion O. <dol...@us...> - 2005-11-15 14:07:52
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12449/magicajax/Core Modified Files: AssemblyInfo.cs MagicAjax NET 2.0.csproj MagicAjaxModule.cs Log Message: Added code for using embedded 'WebParts.js' file inside ASP.NET 2.0 WebPart pages. Index: MagicAjax NET 2.0.csproj =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjax NET 2.0.csproj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MagicAjax NET 2.0.csproj 15 Nov 2005 11:47:52 -0000 1.4 --- MagicAjax NET 2.0.csproj 15 Nov 2005 14:07:31 -0000 1.5 *************** *** 149,152 **** --- 149,153 ---- </Compile> <EmbeddedResource Include="script\AjaxCallObject.js" /> + <EmbeddedResource Include="script\WebParts.js" /> <Content Include="Web.config" /> </ItemGroup> Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/AssemblyInfo.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AssemblyInfo.cs 14 Nov 2005 18:50:43 -0000 1.2 --- AssemblyInfo.cs 15 Nov 2005 14:07:31 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- //Webresources [assembly: WebResourceAttribute("MagicAjax.script.AjaxCallObject.js", "text/javascript")] + [assembly: WebResourceAttribute("MagicAjax.script.WebParts.js", "text/javascript")] #endif Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MagicAjaxModule.cs 15 Nov 2005 11:47:52 -0000 1.7 --- MagicAjaxModule.cs 15 Nov 2005 14:07:31 -0000 1.8 *************** *** 137,141 **** public virtual void EnableAjaxOnPage(Page page) { ! if ( _isAjaxCall ) return; string STARTUP_SCRIPT_FORMAT = @" --- 137,141 ---- public virtual void EnableAjaxOnPage(Page page) { ! if (_isAjaxCall || page == null) return; string STARTUP_SCRIPT_FORMAT = @" *************** *** 189,192 **** --- 189,238 ---- } } + + #if NET_2_0 + /// <summary> + /// Adds WebPart client scriptfile to the page. + /// This scriptfile adds functions to reset the WebPartManager object on the client after a callback + /// </summary> + /// <param name="page"></param> + public virtual void AddWebPartClientFunctions(Page page) + { + if (_isAjaxCall || page == null) return; + + if (!HttpContext.Current.Items.Contains("AJAX_WEBPARTCLIENTSCRIPT_REGISTERED")) + { + // if this is a WebPart page, and IE browser, add our 'WebParts.js' script + System.Web.UI.WebControls.WebParts.WebPartManager wpm = System.Web.UI.WebControls.WebParts.WebPartManager.GetCurrentWebPartManager(page); + if (wpm != null && wpm.EnableClientScript) + { + HttpBrowserCapabilities capabilities = page.Request.Browser; + if (capabilities.Win32 && (capabilities.MSDomVersion.CompareTo(new Version(5, 5)) >= 0)) + { + string location = _config.ScriptPath; + if (location == null) + { + // Use embedded clientscipt resource + page.ClientScript.RegisterClientScriptResource(typeof(MagicAjaxModule), "MagicAjax.script.WebParts.js"); + } + else + { + // Point to external script source file + string includeScript = String.Format("<script type=\"text/javascript\" src=\"{0}/{1}\"></script>", location, "WebParts.js"); + page.RegisterClientScriptBlock("AJAX_WEBPARTCLIENTSCRIPT_REGISTERED", includeScript); + } + + string AJAX_WEBPARTCLIENTSCRIPT_CHECK_FORMAT = @" + <script language='javascript'> + if (typeof(WebPartManager_Cleanup) == 'undefined') + alert(""Unable to find script library '{0}/{1}'. Copy the file to the required location, or change the 'ajaxCallScriptPath' setting at magicAjax section of web.config.""); + </script>"; + + page.RegisterStartupScript("AJAX_WEBPARTCLIENTSCRIPT_CHECK", string.Format(AJAX_WEBPARTCLIENTSCRIPT_CHECK_FORMAT, location, "WebParts.js")); + } + } + HttpContext.Current.Items.Add("AJAX_WEBPARTCLIENTSCRIPT_REGISTERED", true); + } + } + #endif #endregion *************** *** 446,484 **** if (wpmValue != null) { ! //TODO: read wpm_Dispose_script from file ! string wpm_Dispose_script = @" ! // Send script to dispose current webpartmanager ! if (__wpm != null && __wpm.zones != null) ! { ! //loop zones ! for (var i = 0; i < __wpm.zones.length; i++) ! { ! var zone = __wpm.zones[i]; ! //detach current zone events ! if (zone.webPartTable != null) ! { ! zone.webPartTable.detachEvent('ondragenter', Zone_OnDragEnter); ! zone.webPartTable.detachEvent('ondrop', Zone_OnDrop); ! zone.webPartTable.detachEvent('ondrop', Zone_OnDrop); ! } ! //loop webparts of current zone ! if (zone.webParts != null) ! { ! for (var j = 0; j < zone.webParts.length; j++) ! { ! var webpart = zone.webParts[j]; ! //detach current webpart events ! webpart.webPartElement.detachEvent('ondragstart', WebPart_OnDragStart); ! webpart.webPartElement.detachEvent('ondrag', WebPart_OnDrag); ! webpart.webPartElement.detachEvent('ondragend', WebPart_OnDragEnd); ! } ! } ! //dispose zone ! __wpm.zones[i].Dispose(); ! } ! //reset zone array in webpartmanager ! __wpm.zones = new Array(); ! }"; ! AjaxCallHelper.Write(wpm_Dispose_script); // Send script to setup webpartmanager drag&drop + webpartmenu's --- 492,497 ---- if (wpmValue != null) { ! // Send script to cleanup current clientside WebPartManager object ! AjaxCallHelper.Write("if (typeof(WebPartManager_Cleanup) == 'function') { WebPartManager_Cleanup(); }"); // Send script to setup webpartmanager drag&drop + webpartmenu's |
From: Dion O. <dol...@us...> - 2005-11-15 14:07:52
|
Update of /cvsroot/magicajax/magicajax/Core/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12449/magicajax/Core/UI Modified Files: AjaxControl.cs Log Message: Added code for using embedded 'WebParts.js' file inside ASP.NET 2.0 WebPart pages. Index: AjaxControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxControl.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AjaxControl.cs 14 Nov 2005 18:50:43 -0000 1.2 --- AjaxControl.cs 15 Nov 2005 14:07:31 -0000 1.3 *************** *** 61,64 **** --- 61,70 ---- // Register 'AjaxCallObject.js' script MagicAjaxModule.Instance.EnableAjaxOnPage(this.Page); + + #if NET_2_0 + // add WebPartManager script (AddWebPartClientFunctions will check if this page is a WebPartPage) + MagicAjaxModule.Instance.AddWebPartClientFunctions(this.Page); + #endif + base.OnPreRender (e); } |
From: Dion O. <dol...@us...> - 2005-11-15 13:06:27
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31753/magicajax/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Added some comments Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AjaxPanel.cs 15 Nov 2005 12:55:11 -0000 1.6 --- AjaxPanel.cs 15 Nov 2005 13:06:16 -0000 1.7 *************** *** 770,778 **** #region Private Class ControlCollectionState - [Serializable] private class ControlCollectionState { private SortedList _controlIDHtmlHashes; public ControlCollectionState(SortedList controlIDHtmlHashes) { --- 770,789 ---- #region Private Class ControlCollectionState private class ControlCollectionState { private SortedList _controlIDHtmlHashes; + /// <summary> + /// Default ctor + /// </summary> + public ControlCollectionState() + { + _controlIDHtmlHashes = new SortedList(); + } + + /// <summary> + /// Constructs a new ControlCollectionState with a list of controlIDHtmlHashes + /// </summary> + /// <param name="controlIDHtmlHashes"></param> public ControlCollectionState(SortedList controlIDHtmlHashes) { *************** *** 780,783 **** --- 791,799 ---- } + /// <summary> + /// Loads the ControlCollectionState from the hidden form element + /// </summary> + /// <param name="panelUniqueID"></param> + /// <returns></returns> public static ControlCollectionState LoadState(string panelUniqueID) { *************** *** 803,806 **** --- 819,827 ---- } + /// <summary> + /// Returns the ClientID of the hidden field containing the ControlState hashes for given panel + /// </summary> + /// <param name="panelUniqueID"></param> + /// <returns></returns> public static string GetPanelControlStateHiddenFieldID (string panelUniqueID) { *************** *** 820,823 **** --- 841,850 ---- } + /// <summary> + /// Saves the ControlState hashes. + /// When in AjaxCall mode, creates SetFieldScript to set hidden field when last ControlState hashes were changed. + /// </summary> + /// <param name="panelUniqueID"></param> + /// <param name="page"></param> public void Save(string panelUniqueID, Page page) { *************** *** 853,861 **** } - - public ControlCollectionState() - { - _controlIDHtmlHashes = new SortedList(); - } } #endregion --- 880,883 ---- |
From: Dion O. <dol...@us...> - 2005-11-15 12:55:19
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29956/magicajax/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Because MD5 also generates a unique fingerprint (and is quicker than SHA-1), I've replaced the SHA-1 hashing by MD5 hashing Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AjaxPanel.cs 15 Nov 2005 12:38:36 -0000 1.5 --- AjaxPanel.cs 15 Nov 2005 12:55:11 -0000 1.6 *************** *** 186,190 **** if (IsPageNoStoreMode) ! _controlHtmlHashes[control] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); else _controlHtmls[control] = sb.ToString(); --- 186,190 ---- if (IsPageNoStoreMode) ! _controlHtmlHashes[control] = AjaxCallHelper.GetBase64MD5Sum(sb.ToString()); else _controlHtmls[control] = sb.ToString(); *************** *** 299,303 **** if (IsPageNoStoreMode) ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); else _controlHtmls[con] = sb.ToString(); --- 299,303 ---- if (IsPageNoStoreMode) ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64MD5Sum(sb.ToString()); else _controlHtmls[con] = sb.ToString(); *************** *** 419,423 **** if (IsPageNoStoreMode) ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); else _controlHtmls[con] = sb.ToString(); --- 419,423 ---- if (IsPageNoStoreMode) ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64MD5Sum(sb.ToString()); else _controlHtmls[con] = sb.ToString(); *************** *** 462,466 **** if (IsPageNoStoreMode) ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); else _controlHtmls[con] = sb.ToString(); --- 462,466 ---- if (IsPageNoStoreMode) ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64MD5Sum(sb.ToString()); else _controlHtmls[con] = sb.ToString(); *************** *** 473,477 **** if (IsPageNoStoreMode) { ! string htmlHashCode = AjaxCallHelper.GetBase64SHA1Sum(html); // If it's html rendering sha1 hash is the same, ignore it. --- 473,477 ---- if (IsPageNoStoreMode) { ! string htmlHashCode = AjaxCallHelper.GetBase64MD5Sum(html); // If it's html rendering sha1 hash is the same, ignore it. |
From: Dion O. <dol...@us...> - 2005-11-15 12:55:19
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29956/magicajax/Core Modified Files: AjaxCallHelper.cs Log Message: Because MD5 also generates a unique fingerprint (and is quicker than SHA-1), I've replaced the SHA-1 hashing by MD5 hashing Index: AjaxCallHelper.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/AjaxCallHelper.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AjaxCallHelper.cs 15 Nov 2005 11:47:52 -0000 1.2 --- AjaxCallHelper.cs 15 Nov 2005 12:55:11 -0000 1.3 *************** *** 279,290 **** /// <summary> ! /// Create a base64 encoded SHA1 sum string of an input string /// </summary> /// <param name="str"></param> /// <returns></returns> ! static public string GetBase64SHA1Sum(string input) { byte[] inputBytes = UnicodeEncoding.Default.GetBytes(input); ! byte[] hashedBytes = new SHA1CryptoServiceProvider().ComputeHash(inputBytes); return Convert.ToBase64String(hashedBytes); } --- 279,290 ---- /// <summary> ! /// Create a base64 encoded MD5 sum string of an input string /// </summary> /// <param name="str"></param> /// <returns></returns> ! static public string GetBase64MD5Sum(string input) { byte[] inputBytes = UnicodeEncoding.Default.GetBytes(input); ! byte[] hashedBytes = new MD5CryptoServiceProvider().ComputeHash(inputBytes); return Convert.ToBase64String(hashedBytes); } |
From: Dion O. <dol...@us...> - 2005-11-15 12:38:44
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27202/magicajax/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Updated AjaxPanel, so only in NoStore mode the SHA-1 hashes of the output Html is stored (instead of the full html output). I've done this to make sure the 'Session' and 'Cache' modes are untouched by these changes. Later, we can start using the SHA-1 hashes also for 'Session' and 'Cache' modes. Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AjaxPanel.cs 15 Nov 2005 11:47:53 -0000 1.4 --- AjaxPanel.cs 15 Nov 2005 12:38:36 -0000 1.5 *************** *** 82,85 **** --- 82,86 ---- private ArrayList _addedControls = new ArrayList(); private ArrayList _removedControls = new ArrayList(); + private Hashtable _controlHtmls = new Hashtable(); private Hashtable _controlHtmlHashes = new Hashtable(); private NoVerifyRenderingPage _noVerifyPage = new NoVerifyRenderingPage(); *************** *** 184,188 **** ExtendedRenderControl (control, litewriter); ! _controlHtmlHashes[control] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); sb.Length = 0; --- 185,192 ---- ExtendedRenderControl (control, litewriter); ! if (IsPageNoStoreMode) ! _controlHtmlHashes[control] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); ! else ! _controlHtmls[control] = sb.ToString(); sb.Length = 0; *************** *** 203,206 **** --- 207,211 ---- _addedControls.Clear(); _removedControls.Clear(); + _controlHtmls.Clear(); _controlHtmlHashes.Clear(); } *************** *** 293,297 **** writer.Write (sbFull.ToString()); ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); sbFull.Length = 0; --- 298,305 ---- writer.Write (sbFull.ToString()); ! if (IsPageNoStoreMode) ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); ! else ! _controlHtmls[con] = sb.ToString(); sbFull.Length = 0; *************** *** 314,317 **** --- 322,326 ---- protected virtual void SaveControlState() { + //note:only for NoStore mode _controlState.SetControlIDs(_controlHtmlHashes); _controlState.Save (this.UniqueID, this.Page); *************** *** 409,413 **** fullwriter.WriteEndTag ("span"); ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); sb.Length = 0; --- 418,425 ---- fullwriter.WriteEndTag ("span"); ! if (IsPageNoStoreMode) ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); ! else ! _controlHtmls[con] = sb.ToString(); sb.Length = 0; *************** *** 425,429 **** foreach (Control con in _removedControls) { ! _controlHtmlHashes.Remove(con); AjaxCallHelper.WriteRemoveElementScript (ClientID, GetAjaxElemID(con)); } --- 437,445 ---- foreach (Control con in _removedControls) { ! if (IsPageNoStoreMode) ! _controlHtmlHashes.Remove(con); ! else ! _controlHtmls.Remove(con); ! AjaxCallHelper.WriteRemoveElementScript (ClientID, GetAjaxElemID(con)); } *************** *** 445,449 **** output.Write (html); ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); } else --- 461,468 ---- output.Write (html); ! if (IsPageNoStoreMode) ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); ! else ! _controlHtmls[con] = sb.ToString(); } else *************** *** 451,461 **** ExtendedRenderControl (con, output, litewriter); html = sb.ToString(); - string htmlHashCode = AjaxCallHelper.GetBase64SHA1Sum(html); ! // If it's html rendering sha1 hash is the same, ignore it. ! if (htmlHashCode != (string)_controlHtmlHashes[con]) { ! ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); ! _controlHtmlHashes[con] = htmlHashCode; } } --- 470,493 ---- ExtendedRenderControl (con, output, litewriter); html = sb.ToString(); ! if (IsPageNoStoreMode) { ! string htmlHashCode = AjaxCallHelper.GetBase64SHA1Sum(html); ! ! // If it's html rendering sha1 hash is the same, ignore it. ! if (htmlHashCode != (string)_controlHtmlHashes[con]) ! { ! ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); ! _controlHtmlHashes[con] = htmlHashCode; ! } ! } ! else ! { ! // If it's html rendering is the same, ignore it. ! if (html != (string)_controlHtmls[con]) ! { ! ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); ! _controlHtmls[con] = html; ! } } } *************** *** 714,718 **** { Control con = Controls[i]; ! if (!_addedControls.Contains(con) && _controlHtmlHashes[con] != null) return GetAjaxElemID(con); } --- 746,751 ---- { Control con = Controls[i]; ! ! if (!_addedControls.Contains(con) && ((IsPageNoStoreMode && _controlHtmlHashes[con] != null) || (!IsPageNoStoreMode && _controlHtmls[con] != null))) return GetAjaxElemID(con); } *************** *** 772,776 **** public static string GetPanelControlStateHiddenFieldID (string panelUniqueID) { ! return string.Format("__PANELCONTROLSTATE_{0}", panelUniqueID); } --- 805,809 ---- public static string GetPanelControlStateHiddenFieldID (string panelUniqueID) { ! return string.Format("__AJAXPANELCONTROLSTATE_{0}", panelUniqueID); } |
From: Dion O. <dol...@us...> - 2005-11-15 11:48:16
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17135/magicajax/Core Modified Files: AjaxCallHelper.cs MagicAjax NET 2.0.csproj MagicAjaxModule.cs Log Message: Code-changes to use SHA1-hashcode for comparing last generated Html with current generated Html. This saves lots of server memory. Also, the 'NoStore' mode doesn't have to use Session anymore to store it's Html data, but instead uses hidden fields on client (so it's now really 'NoStore'). Index: AjaxCallHelper.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/AjaxCallHelper.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AjaxCallHelper.cs 14 Nov 2005 18:50:43 -0000 1.1 --- AjaxCallHelper.cs 15 Nov 2005 11:47:52 -0000 1.2 *************** *** 25,28 **** --- 25,30 ---- using System.Web.UI; using System.Collections; + using System.Security.Cryptography; + using System.Text; namespace MagicAjax *************** *** 275,278 **** --- 277,293 ---- return url; } + + /// <summary> + /// Create a base64 encoded SHA1 sum string of an input string + /// </summary> + /// <param name="str"></param> + /// <returns></returns> + static public string GetBase64SHA1Sum(string input) + { + byte[] inputBytes = UnicodeEncoding.Default.GetBytes(input); + byte[] hashedBytes = new SHA1CryptoServiceProvider().ComputeHash(inputBytes); + return Convert.ToBase64String(hashedBytes); + } + #endregion Index: MagicAjax NET 2.0.csproj =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjax NET 2.0.csproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MagicAjax NET 2.0.csproj 15 Nov 2005 00:30:53 -0000 1.3 --- MagicAjax NET 2.0.csproj 15 Nov 2005 11:47:52 -0000 1.4 *************** *** 35,39 **** <ConfigurationOverrideFile> </ConfigurationOverrideFile> ! <DefineConstants>TRACE;DEBUG;NET_2_0;CLIENTSIDE_PANELSTATE</DefineConstants> <DocumentationFile> </DocumentationFile> --- 35,39 ---- <ConfigurationOverrideFile> </ConfigurationOverrideFile> ! <DefineConstants>TRACE;DEBUG;NET_2_0</DefineConstants> <DocumentationFile> </DocumentationFile> Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MagicAjaxModule.cs 15 Nov 2005 00:30:53 -0000 1.6 --- MagicAjaxModule.cs 15 Nov 2005 11:47:52 -0000 1.7 *************** *** 434,453 **** } - #if CLIENTSIDE_PANELSTATE - //store hash-states of panel controls - foreach (string key in _context.Items.Keys) - { - if (key.StartsWith("__PANELCONTROLSTATE_")) - { - string keyValue = (string)_context.Items[key]; - if (_request[key] != keyValue) - { - //update - AjaxCallHelper.WriteSetFieldScript(key, keyValue); - } - } - } - #endif - #if NET_2_0 // Check if this request is to add/remove/replace a WebPart --- 434,437 ---- |
From: Dion O. <dol...@us...> - 2005-11-15 11:48:05
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17135/magicajax/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Code-changes to use SHA1-hashcode for comparing last generated Html with current generated Html. This saves lots of server memory. Also, the 'NoStore' mode doesn't have to use Session anymore to store it's Html data, but instead uses hidden fields on client (so it's now really 'NoStore'). Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AjaxPanel.cs 15 Nov 2005 00:30:54 -0000 1.3 --- AjaxPanel.cs 15 Nov 2005 11:47:53 -0000 1.4 *************** *** 82,90 **** private ArrayList _addedControls = new ArrayList(); private ArrayList _removedControls = new ArrayList(); - #if CLIENTSIDE_PANELSTATE private Hashtable _controlHtmlHashes = new Hashtable(); - #else - private Hashtable _controlHtmls = new Hashtable(); - #endif private NoVerifyRenderingPage _noVerifyPage = new NoVerifyRenderingPage(); private ControlCollectionState _controlState = new ControlCollectionState(); --- 82,86 ---- *************** *** 188,196 **** ExtendedRenderControl (control, litewriter); ! #if CLIENTSIDE_PANELSTATE ! _controlHtmlHashes[control] = sb.ToString().GetHashCode(); ! #else ! _controlHtmls[control] = sb.ToString(); ! #endif sb.Length = 0; } --- 184,189 ---- ExtendedRenderControl (control, litewriter); ! _controlHtmlHashes[control] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); ! sb.Length = 0; } *************** *** 210,218 **** _addedControls.Clear(); _removedControls.Clear(); - #if CLIENTSIDE_PANELSTATE _controlHtmlHashes.Clear(); - #else - _controlHtmls.Clear(); - #endif } #endregion --- 203,207 ---- *************** *** 303,311 **** ExtendedRenderControl (con, fullwriter, litewriter); writer.Write (sbFull.ToString()); ! #if CLIENTSIDE_PANELSTATE ! _controlHtmlHashes[con] = sb.ToString().GetHashCode(); ! #else ! _controlHtmls[con] = sb.ToString(); ! #endif sbFull.Length = 0; sb.Length = 0; --- 292,298 ---- ExtendedRenderControl (con, fullwriter, litewriter); writer.Write (sbFull.ToString()); ! ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); ! sbFull.Length = 0; sb.Length = 0; *************** *** 327,335 **** protected virtual void SaveControlState() { - #if CLIENTSIDE_PANELSTATE _controlState.SetControlIDs(_controlHtmlHashes); - #else - _controlState.SetControlIDs (_controlHtmls); - #endif _controlState.Save (this.UniqueID, this.Page); } --- 314,318 ---- *************** *** 347,364 **** // Find new and previous controls _addedControls.Clear(); - #if CLIENTSIDE_PANELSTATE _controlHtmlHashes.Clear(); ! #else ! _controlHtmls.Clear(); ! #endif foreach (Control con in this.Controls) { if ( _controlState.ControlIDHtmls.ContainsKey(con.ClientID) ) { - #if CLIENTSIDE_PANELSTATE _controlHtmlHashes[con] = _controlState.ControlIDHtmls[con.ClientID]; - #else - _controlHtmls[con] = _controlState.ControlIDHtmls[con.ClientID]; - #endif } else --- 330,340 ---- // Find new and previous controls _addedControls.Clear(); _controlHtmlHashes.Clear(); ! foreach (Control con in this.Controls) { if ( _controlState.ControlIDHtmls.ContainsKey(con.ClientID) ) { _controlHtmlHashes[con] = _controlState.ControlIDHtmls[con.ClientID]; } else *************** *** 432,440 **** fullwriter.WriteEndTag ("span"); ! #if CLIENTSIDE_PANELSTATE ! _controlHtmlHashes[con] = sb.ToString().GetHashCode(); ! #else ! _controlHtmls[con] = sb.ToString(); ! #endif sb.Length = 0; } --- 408,414 ---- fullwriter.WriteEndTag ("span"); ! ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); ! sb.Length = 0; } *************** *** 451,459 **** foreach (Control con in _removedControls) { - #if CLIENTSIDE_PANELSTATE _controlHtmlHashes.Remove(con); - #else - _controlHtmls.Remove (con); - #endif AjaxCallHelper.WriteRemoveElementScript (ClientID, GetAjaxElemID(con)); } --- 425,429 ---- *************** *** 474,482 **** AjaxCallHelper.WriteAddElementScript (ClientID, "span", GetAjaxElemID(con), html, GetNextExistingElement(i)); output.Write (html); ! #if CLIENTSIDE_PANELSTATE ! _controlHtmlHashes[con] = sb.ToString().GetHashCode(); ! #else ! _controlHtmls[con] = sb.ToString(); ! #endif } else --- 444,449 ---- AjaxCallHelper.WriteAddElementScript (ClientID, "span", GetAjaxElemID(con), html, GetNextExistingElement(i)); output.Write (html); ! ! _controlHtmlHashes[con] = AjaxCallHelper.GetBase64SHA1Sum(sb.ToString()); } else *************** *** 484,503 **** ExtendedRenderControl (con, output, litewriter); html = sb.ToString(); ! #if CLIENTSIDE_PANELSTATE ! int htmlHashCode = html.GetHashCode(); ! // If it's html rendering hash is the same, ignore it. ! if (htmlHashCode != (int)_controlHtmlHashes[con]) { ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); _controlHtmlHashes[con] = htmlHashCode; } - #else - // If it's html rendering is the same, ignore it. - if (html != (string)_controlHtmls[con]) - { - ExtendedWriteSetHtmlOfElementScript (html, GetAjaxElemID(con)); - _controlHtmls[con] = html; - } - #endif } } --- 451,462 ---- ExtendedRenderControl (con, output, litewriter); html = sb.ToString(); ! string htmlHashCode = AjaxCallHelper.GetBase64SHA1Sum(html); ! ! // If it's html rendering sha1 hash is the same, ignore it. ! if (htmlHashCode != (string)_controlHtmlHashes[con]) { ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); _controlHtmlHashes[con] = htmlHashCode; } } } *************** *** 755,765 **** { Control con = Controls[i]; - #if CLIENTSIDE_PANELSTATE if (!_addedControls.Contains(con) && _controlHtmlHashes[con] != null) return GetAjaxElemID(con); - #else - if (!_addedControls.Contains(con) && _controlHtmls[con] != null) - return GetAjaxElemID(con); - #endif } --- 714,719 ---- *************** *** 786,790 **** private class ControlCollectionState { - #if CLIENTSIDE_PANELSTATE private SortedList _controlIDHtmlHashes; --- 740,743 ---- *************** *** 793,804 **** _controlIDHtmlHashes = controlIDHtmlHashes; } - #else - private Hashtable _controlIDHtmls; - #endif public static ControlCollectionState LoadState(string panelUniqueID) { ! #if CLIENTSIDE_PANELSTATE ! string panelKey = "__PANELCONTROLSTATE_" + panelUniqueID; string panelControlStates = HttpContext.Current.Request.Form[panelKey]; if (panelControlStates != null) --- 746,753 ---- _controlIDHtmlHashes = controlIDHtmlHashes; } public static ControlCollectionState LoadState(string panelUniqueID) { ! string panelKey = GetPanelControlStateHiddenFieldID(panelUniqueID); string panelControlStates = HttpContext.Current.Request.Form[panelKey]; if (panelControlStates != null) *************** *** 810,819 **** string namevaluepair = namevaluepairs[i]; string[] namevalue = namevaluepair.Split('#'); ! controlIDHtmlHashes.Add(string.Format("{0}_{1}", panelUniqueID, namevalue[0]), int.Parse(namevalue[1], CultureInfo.InvariantCulture)); } return new ControlCollectionState(controlIDHtmlHashes); - - //return new ControlCollectionState((Hashtable)AjaxCallHelper.DeserializeFromString(panelControlStates)); } else --- 759,766 ---- string namevaluepair = namevaluepairs[i]; string[] namevalue = namevaluepair.Split('#'); ! controlIDHtmlHashes.Add(string.Format("{0}_{1}", panelUniqueID, namevalue[0]), namevalue[1]); } return new ControlCollectionState(controlIDHtmlHashes); } else *************** *** 821,863 **** return null; } - #else - return (ControlCollectionState) HttpContext.Current.Session[GetPageKey(panelUniqueID)]; - #endif } ! public static string GetPageKey (string panelUniqueID) { ! return String.Format("__ControlState_{0}_{1}", HttpContext.Current.Request.RawUrl, panelUniqueID); } - #if CLIENTSIDE_PANELSTATE public System.Collections.SortedList ControlIDHtmls { get { return _controlIDHtmlHashes; } } - #else - public Hashtable ControlIDHtmls - { - get { return _controlIDHtmls; } - } - #endif ! public void SetControlIDs (Hashtable controlHtmls) { - #if CLIENTSIDE_PANELSTATE _controlIDHtmlHashes.Clear(); ! foreach (Control con in controlHtmls.Keys) ! _controlIDHtmlHashes.Add(con.ClientID, (int)controlHtmls[con]); ! #else ! _controlIDHtmls.Clear(); ! foreach (Control con in controlHtmls.Keys) ! _controlIDHtmls.Add (con.ClientID, (string)controlHtmls[con]); ! #endif } public void Save(string panelUniqueID, Page page) { ! #if CLIENTSIDE_PANELSTATE ! System.Text.StringBuilder serializedContolStates = new System.Text.StringBuilder(); foreach (string key in _controlIDHtmlHashes.Keys) --- 768,793 ---- return null; } } ! public static string GetPanelControlStateHiddenFieldID (string panelUniqueID) { ! return string.Format("__PANELCONTROLSTATE_{0}", panelUniqueID); } public System.Collections.SortedList ControlIDHtmls { get { return _controlIDHtmlHashes; } } ! public void SetControlIDs (Hashtable controlHtmlHashes) { _controlIDHtmlHashes.Clear(); ! foreach (Control con in controlHtmlHashes.Keys) ! _controlIDHtmlHashes.Add(con.ClientID, (string)controlHtmlHashes[con]); } public void Save(string panelUniqueID, Page page) { ! System.Text.StringBuilder sbuilder = new System.Text.StringBuilder(); foreach (string key in _controlIDHtmlHashes.Keys) *************** *** 865,892 **** if (_controlIDHtmlHashes.IndexOfKey(key) > 0) { ! serializedContolStates.Append(';'); } string keyWithoutNamingcontainer = key.Substring(panelUniqueID.Length + 1); ! serializedContolStates.AppendFormat("{0}#{1}", keyWithoutNamingcontainer, ((int)_controlIDHtmlHashes[key]).ToString(CultureInfo.InvariantCulture)); } ! page.RegisterHiddenField("__PANELCONTROLSTATE_" + panelUniqueID, ! serializedContolStates.ToString()); ! HttpContext.Current.Items.Add("__PANELCONTROLSTATE_" + panelUniqueID, ! serializedContolStates.ToString()); ! #else ! HttpContext.Current.Session[GetPageKey(panelUniqueID)] = this; ! #endif } public ControlCollectionState() { - #if CLIENTSIDE_PANELSTATE _controlIDHtmlHashes = new SortedList(); - #else - _controlIDHtmls = new Hashtable(); - #endif } } --- 795,827 ---- if (_controlIDHtmlHashes.IndexOfKey(key) > 0) { ! sbuilder.Append(';'); } string keyWithoutNamingcontainer = key.Substring(panelUniqueID.Length + 1); ! sbuilder.AppendFormat("{0}#{1}", keyWithoutNamingcontainer, _controlIDHtmlHashes[key]); } ! string serializedPanelStateHashes = sbuilder.ToString(); ! string panelKey = GetPanelControlStateHiddenFieldID(panelUniqueID); ! ! if (AjaxCallHelper.IsAjaxCall) ! { ! //if ajax callback, generate javascript to set panelstate's hidden field value ! if (HttpContext.Current.Request.Form[panelKey] != serializedPanelStateHashes) ! { ! AjaxCallHelper.WriteSetFieldScript(panelKey, serializedPanelStateHashes); ! } ! } ! else ! { ! page.RegisterHiddenField(panelKey, serializedPanelStateHashes); ! } ! } public ControlCollectionState() { _controlIDHtmlHashes = new SortedList(); } } |
From: Dion O. <dol...@us...> - 2005-11-15 00:35:18
|
Update of /cvsroot/magicajax/magicajax/Core/Interfaces In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8430/magicajax/Core/Interfaces Removed Files: ICallBackEventHandler.cs Log Message: Removed unused files --- ICallBackEventHandler.cs DELETED --- |
From: Dion O. <dol...@us...> - 2005-11-15 00:35:18
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8430/magicajax/Core Removed Files: CallBackHelper.cs Log Message: Removed unused files --- CallBackHelper.cs DELETED --- |
From: Dion O. <dol...@us...> - 2005-11-15 00:35:18
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8430/magicajax/Core/script Removed Files: CallBackObject.js Log Message: Removed unused files --- CallBackObject.js DELETED --- |
From: Dion O. <dol...@us...> - 2005-11-15 00:31:07
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7835/magicajax/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Added an alternative panelcontrolstate storage (in hidden form element, instead of Session). To test it, compile with CLIENTSIDE_PANELSTATE (compilation symbol) Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AjaxPanel.cs 14 Nov 2005 18:50:43 -0000 1.2 --- AjaxPanel.cs 15 Nov 2005 00:30:54 -0000 1.3 *************** *** 27,30 **** --- 27,31 ---- using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; + using System.Globalization; namespace MagicAjax.UI.Controls *************** *** 81,85 **** --- 82,90 ---- private ArrayList _addedControls = new ArrayList(); private ArrayList _removedControls = new ArrayList(); + #if CLIENTSIDE_PANELSTATE + private Hashtable _controlHtmlHashes = new Hashtable(); + #else private Hashtable _controlHtmls = new Hashtable(); + #endif private NoVerifyRenderingPage _noVerifyPage = new NoVerifyRenderingPage(); private ControlCollectionState _controlState = new ControlCollectionState(); *************** *** 182,187 **** ExtendedRenderControl (control, litewriter); ! _controlHtmls[control] = sb.ToString(); sb.Length = 0; } --- 187,196 ---- ExtendedRenderControl (control, litewriter); ! ! #if CLIENTSIDE_PANELSTATE ! _controlHtmlHashes[control] = sb.ToString().GetHashCode(); ! #else _controlHtmls[control] = sb.ToString(); + #endif sb.Length = 0; } *************** *** 201,205 **** --- 210,218 ---- _addedControls.Clear(); _removedControls.Clear(); + #if CLIENTSIDE_PANELSTATE + _controlHtmlHashes.Clear(); + #else _controlHtmls.Clear(); + #endif } #endregion *************** *** 290,294 **** --- 303,311 ---- ExtendedRenderControl (con, fullwriter, litewriter); writer.Write (sbFull.ToString()); + #if CLIENTSIDE_PANELSTATE + _controlHtmlHashes[con] = sb.ToString().GetHashCode(); + #else _controlHtmls[con] = sb.ToString(); + #endif sbFull.Length = 0; sb.Length = 0; *************** *** 310,315 **** protected virtual void SaveControlState() { _controlState.SetControlIDs (_controlHtmls); ! _controlState.Save (this.UniqueID); } --- 327,336 ---- protected virtual void SaveControlState() { + #if CLIENTSIDE_PANELSTATE + _controlState.SetControlIDs(_controlHtmlHashes); + #else _controlState.SetControlIDs (_controlHtmls); ! #endif ! _controlState.Save (this.UniqueID, this.Page); } *************** *** 326,335 **** --- 347,364 ---- // Find new and previous controls _addedControls.Clear(); + #if CLIENTSIDE_PANELSTATE + _controlHtmlHashes.Clear(); + #else _controlHtmls.Clear(); + #endif foreach (Control con in this.Controls) { if ( _controlState.ControlIDHtmls.ContainsKey(con.ClientID) ) { + #if CLIENTSIDE_PANELSTATE + _controlHtmlHashes[con] = _controlState.ControlIDHtmls[con.ClientID]; + #else _controlHtmls[con] = _controlState.ControlIDHtmls[con.ClientID]; + #endif } else *************** *** 403,408 **** fullwriter.WriteEndTag ("span"); ! _controlHtmls[con] = sb.ToString(); sb.Length = 0; } --- 432,440 ---- fullwriter.WriteEndTag ("span"); ! #if CLIENTSIDE_PANELSTATE ! _controlHtmlHashes[con] = sb.ToString().GetHashCode(); ! #else _controlHtmls[con] = sb.ToString(); + #endif sb.Length = 0; } *************** *** 419,423 **** --- 451,459 ---- foreach (Control con in _removedControls) { + #if CLIENTSIDE_PANELSTATE + _controlHtmlHashes.Remove(con); + #else _controlHtmls.Remove (con); + #endif AjaxCallHelper.WriteRemoveElementScript (ClientID, GetAjaxElemID(con)); } *************** *** 438,443 **** AjaxCallHelper.WriteAddElementScript (ClientID, "span", GetAjaxElemID(con), html, GetNextExistingElement(i)); output.Write (html); ! _controlHtmls[con] = sb.ToString(); } else --- 474,482 ---- AjaxCallHelper.WriteAddElementScript (ClientID, "span", GetAjaxElemID(con), html, GetNextExistingElement(i)); output.Write (html); ! #if CLIENTSIDE_PANELSTATE ! _controlHtmlHashes[con] = sb.ToString().GetHashCode(); ! #else _controlHtmls[con] = sb.ToString(); + #endif } else *************** *** 445,449 **** ExtendedRenderControl (con, output, litewriter); html = sb.ToString(); ! // If it's html rendering is the same, ignore it. if (html != (string)_controlHtmls[con]) --- 484,496 ---- ExtendedRenderControl (con, output, litewriter); html = sb.ToString(); ! #if CLIENTSIDE_PANELSTATE ! int htmlHashCode = html.GetHashCode(); ! // If it's html rendering hash is the same, ignore it. ! if (htmlHashCode != (int)_controlHtmlHashes[con]) ! { ! ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); ! _controlHtmlHashes[con] = htmlHashCode; ! } ! #else // If it's html rendering is the same, ignore it. if (html != (string)_controlHtmls[con]) *************** *** 452,455 **** --- 499,503 ---- _controlHtmls[con] = html; } + #endif } } *************** *** 707,712 **** --- 755,765 ---- { Control con = Controls[i]; + #if CLIENTSIDE_PANELSTATE + if (!_addedControls.Contains(con) && _controlHtmlHashes[con] != null) + return GetAjaxElemID(con); + #else if (!_addedControls.Contains(con) && _controlHtmls[con] != null) return GetAjaxElemID(con); + #endif } *************** *** 731,741 **** #region Private Class ControlCollectionState [Serializable] ! private class ControlCollectionState { private Hashtable _controlIDHtmls; public static ControlCollectionState LoadState(string panelUniqueID) { return (ControlCollectionState) HttpContext.Current.Session[GetPageKey(panelUniqueID)]; } --- 784,827 ---- #region Private Class ControlCollectionState [Serializable] ! private class ControlCollectionState { + #if CLIENTSIDE_PANELSTATE + private SortedList _controlIDHtmlHashes; + + public ControlCollectionState(SortedList controlIDHtmlHashes) + { + _controlIDHtmlHashes = controlIDHtmlHashes; + } + #else private Hashtable _controlIDHtmls; + #endif public static ControlCollectionState LoadState(string panelUniqueID) { + #if CLIENTSIDE_PANELSTATE + string panelKey = "__PANELCONTROLSTATE_" + panelUniqueID; + string panelControlStates = HttpContext.Current.Request.Form[panelKey]; + if (panelControlStates != null) + { + SortedList controlIDHtmlHashes = new SortedList(); + string[] namevaluepairs = panelControlStates.Split(';'); + for (int i = 0; i < namevaluepairs.Length; i++) + { + string namevaluepair = namevaluepairs[i]; + string[] namevalue = namevaluepair.Split('#'); + controlIDHtmlHashes.Add(string.Format("{0}_{1}", panelUniqueID, namevalue[0]), int.Parse(namevalue[1], CultureInfo.InvariantCulture)); + } + + return new ControlCollectionState(controlIDHtmlHashes); + + //return new ControlCollectionState((Hashtable)AjaxCallHelper.DeserializeFromString(panelControlStates)); + } + else + { + return null; + } + #else return (ControlCollectionState) HttpContext.Current.Session[GetPageKey(panelUniqueID)]; + #endif } *************** *** 745,768 **** } public Hashtable ControlIDHtmls { get { return _controlIDHtmls; } } public void SetControlIDs (Hashtable controlHtmls) { _controlIDHtmls.Clear(); foreach (Control con in controlHtmls.Keys) _controlIDHtmls.Add (con.ClientID, (string)controlHtmls[con]); } ! public void Save(string panelUniqueID) { HttpContext.Current.Session[GetPageKey(panelUniqueID)] = this; } public ControlCollectionState() { _controlIDHtmls = new Hashtable(); } } --- 831,892 ---- } + #if CLIENTSIDE_PANELSTATE + public System.Collections.SortedList ControlIDHtmls + { + get { return _controlIDHtmlHashes; } + } + #else public Hashtable ControlIDHtmls { get { return _controlIDHtmls; } } + #endif public void SetControlIDs (Hashtable controlHtmls) { + #if CLIENTSIDE_PANELSTATE + _controlIDHtmlHashes.Clear(); + foreach (Control con in controlHtmls.Keys) + _controlIDHtmlHashes.Add(con.ClientID, (int)controlHtmls[con]); + #else _controlIDHtmls.Clear(); foreach (Control con in controlHtmls.Keys) _controlIDHtmls.Add (con.ClientID, (string)controlHtmls[con]); + #endif } ! public void Save(string panelUniqueID, Page page) { + #if CLIENTSIDE_PANELSTATE + System.Text.StringBuilder serializedContolStates = new System.Text.StringBuilder(); + + foreach (string key in _controlIDHtmlHashes.Keys) + { + if (_controlIDHtmlHashes.IndexOfKey(key) > 0) + { + serializedContolStates.Append(';'); + } + + string keyWithoutNamingcontainer = key.Substring(panelUniqueID.Length + 1); + + serializedContolStates.AppendFormat("{0}#{1}", keyWithoutNamingcontainer, ((int)_controlIDHtmlHashes[key]).ToString(CultureInfo.InvariantCulture)); + } + + page.RegisterHiddenField("__PANELCONTROLSTATE_" + panelUniqueID, + serializedContolStates.ToString()); + HttpContext.Current.Items.Add("__PANELCONTROLSTATE_" + panelUniqueID, + serializedContolStates.ToString()); + #else HttpContext.Current.Session[GetPageKey(panelUniqueID)] = this; + #endif } public ControlCollectionState() { + #if CLIENTSIDE_PANELSTATE + _controlIDHtmlHashes = new SortedList(); + #else _controlIDHtmls = new Hashtable(); + #endif } } |
From: Dion O. <dol...@us...> - 2005-11-15 00:31:01
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7835/magicajax/Core Modified Files: MagicAjax NET 2.0.csproj MagicAjaxModule.cs Log Message: Added an alternative panelcontrolstate storage (in hidden form element, instead of Session). To test it, compile with CLIENTSIDE_PANELSTATE (compilation symbol) Index: MagicAjax NET 2.0.csproj =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjax NET 2.0.csproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MagicAjax NET 2.0.csproj 11 Nov 2005 22:29:39 -0000 1.2 --- MagicAjax NET 2.0.csproj 15 Nov 2005 00:30:53 -0000 1.3 *************** *** 35,39 **** <ConfigurationOverrideFile> </ConfigurationOverrideFile> ! <DefineConstants>TRACE;DEBUG;NET_2_0</DefineConstants> <DocumentationFile> </DocumentationFile> --- 35,39 ---- <ConfigurationOverrideFile> </ConfigurationOverrideFile> ! <DefineConstants>TRACE;DEBUG;NET_2_0;CLIENTSIDE_PANELSTATE</DefineConstants> <DocumentationFile> </DocumentationFile> *************** *** 95,104 **** </ItemGroup> <ItemGroup> <Compile Include="AssemblyInfo.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="CallBackHelper.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="Collections\ReadOnlyArrayList.cs"> <SubType>Code</SubType> --- 95,102 ---- </ItemGroup> <ItemGroup> + <Compile Include="AjaxCallHelper.cs" /> <Compile Include="AssemblyInfo.cs"> <SubType>Code</SubType> </Compile> <Compile Include="Collections\ReadOnlyArrayList.cs"> <SubType>Code</SubType> *************** *** 110,116 **** <SubType>Code</SubType> </Compile> ! <Compile Include="Interfaces\ICallBackEventHandler.cs"> ! <SubType>Code</SubType> ! </Compile> <Compile Include="Interfaces\IFormDataLoadedEventHandler.cs"> <SubType>Code</SubType> --- 108,112 ---- <SubType>Code</SubType> </Compile> ! <Compile Include="Interfaces\IAjaxCallEventHandler.cs" /> <Compile Include="Interfaces\IFormDataLoadedEventHandler.cs"> <SubType>Code</SubType> *************** *** 152,157 **** <SubType>Code</SubType> </Compile> <Content Include="Web.config" /> - <EmbeddedResource Include="script\CallBackObject.js" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> --- 148,153 ---- <SubType>Code</SubType> </Compile> + <EmbeddedResource Include="script\AjaxCallObject.js" /> <Content Include="Web.config" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MagicAjaxModule.cs 14 Nov 2005 18:50:43 -0000 1.5 --- MagicAjaxModule.cs 15 Nov 2005 00:30:53 -0000 1.6 *************** *** 434,437 **** --- 434,453 ---- } + #if CLIENTSIDE_PANELSTATE + //store hash-states of panel controls + foreach (string key in _context.Items.Keys) + { + if (key.StartsWith("__PANELCONTROLSTATE_")) + { + string keyValue = (string)_context.Items[key]; + if (_request[key] != keyValue) + { + //update + AjaxCallHelper.WriteSetFieldScript(key, keyValue); + } + } + } + #endif + #if NET_2_0 // Check if this request is to add/remove/replace a WebPart |
From: Argiris K. <be...@us...> - 2005-11-14 18:50:55
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30932/Core Modified Files: AssemblyInfo.cs MagicAjax.csproj MagicAjaxModule.cs NoVerifyRenderingPage.cs StoredPageInfo.cs Web.config Added Files: AjaxCallHelper.cs Log Message: Replaced all "CallBack" references by "AjaxCall" Index: NoVerifyRenderingPage.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/NoVerifyRenderingPage.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NoVerifyRenderingPage.cs 11 Nov 2005 06:17:49 -0000 1.1 --- NoVerifyRenderingPage.cs 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 32,36 **** /// </summary> /// <remarks> ! /// The controls that require to be inside a form cannot be rendered during a CallBack /// because of the VerifyRenderingInServerForm method of the Page. This class /// can be used to set the Page property of the controls and thus disabling --- 32,36 ---- /// </summary> /// <remarks> ! /// The controls that require to be inside a form cannot be rendered during an AjaxCall /// because of the VerifyRenderingInServerForm method of the Page. This class /// can be used to set the Page property of the controls and thus disabling *************** *** 56,60 **** if (control is IValidator) { ! if ( ! CallBackHelper.IsCallBack && HttpContext.Current.Handler is Page ) { // NoVerifyRenderingPage is used event during normal rendering, --- 56,60 ---- if (control is IValidator) { ! if ( ! AjaxCallHelper.IsAjaxCall && HttpContext.Current.Handler is Page ) { // NoVerifyRenderingPage is used event during normal rendering, *************** *** 66,70 **** } ! // The error message doesn't get visible during a CallBack. // Do it manually. IValidator valid = (IValidator) control; --- 66,70 ---- } ! // The error message doesn't get visible during an AjaxCall. // Do it manually. IValidator valid = (IValidator) control; Index: MagicAjax.csproj =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjax.csproj,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MagicAjax.csproj 11 Nov 2005 06:17:49 -0000 1.1 --- MagicAjax.csproj 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 95,104 **** <Include> <File ! RelPath = "AssemblyInfo.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "CallBackHelper.cs" SubType = "Code" BuildAction = "Compile" --- 95,104 ---- <Include> <File ! RelPath = "AjaxCallHelper.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "AssemblyInfo.cs" SubType = "Code" BuildAction = "Compile" *************** *** 144,148 **** /> <File ! RelPath = "Interfaces\ICallBackEventHandler.cs" SubType = "Code" BuildAction = "Compile" --- 144,148 ---- /> <File ! RelPath = "Interfaces\IAjaxCallEventHandler.cs" SubType = "Code" BuildAction = "Compile" *************** *** 164,168 **** /> <File ! RelPath = "script\CallBackObject.js" BuildAction = "EmbeddedResource" /> --- 164,168 ---- /> <File ! RelPath = "script\AjaxCallObject.js" BuildAction = "EmbeddedResource" /> Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/AssemblyInfo.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AssemblyInfo.cs 11 Nov 2005 06:17:49 -0000 1.1 --- AssemblyInfo.cs 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 21,25 **** #if NET_2_0 //Webresources ! [assembly: WebResourceAttribute("MagicAjax.script.CallBackObject.js", "text/javascript")] #endif --- 21,25 ---- #if NET_2_0 //Webresources ! [assembly: WebResourceAttribute("MagicAjax.script.AjaxCallObject.js", "text/javascript")] #endif Index: StoredPageInfo.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/StoredPageInfo.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StoredPageInfo.cs 11 Nov 2005 06:17:49 -0000 1.1 --- StoredPageInfo.cs 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 10,14 **** { private Page _page; ! private int _callBacksCount; private DateTime _lastAccess; --- 10,14 ---- { private Page _page; ! private int _ajaxCallsCount; private DateTime _lastAccess; *************** *** 18,25 **** } ! public int CallBacksCount { ! get { return _callBacksCount; } ! set { _callBacksCount = value; } } --- 18,25 ---- } ! public int AjaxCallsCount { ! get { return _ajaxCallsCount; } ! set { _ajaxCallsCount = value; } } *************** *** 33,37 **** { _page = page; ! _callBacksCount = 0; _lastAccess = DateTime.Now; } --- 33,37 ---- { _page = page; ! _ajaxCallsCount = 0; _lastAccess = DateTime.Now; } --- NEW FILE: AjaxCallHelper.cs --- #region LGPL License /* MagicAjax Library Copyright (C) 2005 MagicAjax Project Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.Configuration; using System.Web; using System.Web.UI; using System.Collections; namespace MagicAjax { /// <summary> /// Defines the various AjaxCall types /// </summary> public enum AjaxCallType { /// <summary> /// Client didn't invoke an AjaxCall /// </summary> None, /// <summary> /// Standard AjaxCall invoked by a control on the page /// </summary> Control, /// <summary> /// AjaxCall invoked by the AjaxCallTimer /// </summary> Timer } /// <summary> /// Helper functions for AjaxCall handling. /// </summary> public sealed class AjaxCallHelper { private AjaxCallHelper() { } private static System.Text.StringBuilder sbScript = null; #region Static Properties /// <summary> /// Returns the AjaxCall type, suitable for a switch block. /// </summary> public static AjaxCallType AjaxCallType { get { if ( IsAjaxCallTimer ) return AjaxCallType.Timer; else if ( IsAjaxCall ) return AjaxCallType.Control; else return AjaxCallType.None; } } /// <summary> /// Determines whether an AjaxCall was invoked on the server by the client. /// </summary> public static bool IsAjaxCall { get { return ( MagicAjaxModule.Instance.IsAjaxCall ); } } /// <summary> /// Gets the argument string the was sent by the client. /// </summary> public static string AjaxCallArgument { get { if ( IsAjaxCall ) return MagicAjaxModule.Instance.Form["__EVENTARGUMENT"]; else return null; } } /// <summary> /// Determines whether the AjaxCall occured by the AjaxCallTimer. /// </summary> /// <remarks> /// See the remarks of the SetAjaxCallTimerInterval method. /// </remarks> public static bool IsAjaxCallTimer { get { return ( MagicAjaxModule.Instance.Form["__EVENTTARGET"] == "__AJAX_AjaxCallTimer" ); } } /// <summary> /// Gets the name of the javascript function that is used for AjaxCalls from /// the client. /// </summary> public static string AjaxCallClientFunction { get { return "AJAXCbo.DoAjaxCall"; } } /// <summary> /// Included for convenience. /// </summary> public static HttpContext Context { get { return System.Web.HttpContext.Current; } } /// <summary> /// Included for convenience. /// </summary> public static HttpResponse Response { get { HttpResponse hr = System.Web.HttpContext.Current.Response; if (hr == null) throw new MagicAjaxException("AjaxCallHelper could not access current HttpResponse object"); return hr; } } /// <summary> /// Included for convenience. /// </summary> public static HttpRequest Request { get { HttpRequest hr = System.Web.HttpContext.Current.Request; if (hr == null) throw new MagicAjaxException("AjaxCallHelper could not access current HttpRequest object"); return hr; } } #endregion #region Static Methods /// <summary> /// Obtains a reference to a client-side script function that causes, when invoked, /// the control to raise an AjaxCall event to the server. This method also passes /// a parameter to the server control that performs the post-back processing on /// the server. /// </summary> /// <example> /// // Replaces the submit function of the button with the AjaxCall invoking function. /// btnSend.Attributes.Add ("onclick", AjaxCallHelper.GetAjaxCallEventReference(btnSend) + " return false;"); /// </example> /// <param name="control"></param> /// <param name="argument"></param> /// <returns></returns> public static string GetAjaxCallEventReference(Control control, string argument, bool isAsynchronous) { if (control == null) throw new ArgumentNullException("control"); return String.Format("{0}('{1}','{2}','{3}');", AjaxCallClientFunction, control.UniqueID, argument, (isAsynchronous) ? "async" : "sync"); } /// <summary> /// Obtains a reference to a client-side script function that causes, when invoked, /// the control to raise an AjaxCall event to the server. This method also passes /// a parameter to the server control that performs the post-back processing on /// the server. /// </summary> /// <example> /// // Replaces the submit function of the button with the AjaxCall invoking function. /// btnSend.Attributes.Add ("onclick", AjaxCallHelper.GetAjaxCallEventReference(btnSend) + " return false;"); /// </example> /// <param name="control"></param> /// <param name="argument"></param> /// <returns></returns> public static string GetAjaxCallEventReference(Control control, string argument) { if (control == null) throw new ArgumentNullException("control"); return GetAjaxCallEventReference(control, argument, true); } /// <summary> /// Obtains a reference to a client-side script function that causes, when invoked, /// the control to raise an AjaxCall event to the server. /// </summary> /// <example> /// // Replaces the submit function of the button with the AjaxCall invoking function. /// btnSend.Attributes.Add ("onclick", AjaxCallHelper.GetAjaxCallEventReference(btnSend) + " return false;"); /// </example> /// <param name="control"></param> /// <returns></returns> public static string GetAjaxCallEventReference(Control control) { return GetAjaxCallEventReference(control, "", true); } /// <summary> /// Appends javascript: to the beginning of the return from a /// GetAjaxCallEventReference call to allow hyperlink AjaxCall processing on the /// server. /// </summary> /// <param name="control"></param> /// <param name="argument"></param> /// <returns></returns> public static string GetAjaxCallClientHyperlink(Control control, string argument) { return String.Format("javascript:{0}", GetAjaxCallEventReference(control, argument)); } /// <summary> /// Defines the time between repeated automatic AjaxCalls of the page. /// </summary> /// <param name="milliSeconds">Set it to zero in order to disable AjaxCallTimer</param> public static void SetAjaxCallTimerInterval(int milliSeconds) { if (milliSeconds > 0) { if ( IsAjaxCall ) Write (String.Format("AJAXCbo.SetIntervalForAjaxCall({0});", milliSeconds)); else { //EnableAjaxOnPage(); Page page = (Page) HttpContext.Current.Handler; page.RegisterStartupScript ("AJAX_AjaxCallTimer_SCRIPT", String.Format("<script language=\"javascript\">AJAXCbo.SetIntervalForAjaxCall({0});</script>", milliSeconds)); } } else { if ( IsAjaxCall ) Write ("AJAXCbo.ClearIntervalForAjaxCall();"); else throw new MagicAjaxException("AjaxCallTimer can be cleared only during an AjaxCall."); } } /// <summary> /// Resolves relative url's (starting with "~"). /// Use this when Control.ResolveUrl() is not available. /// </summary> /// <param name="url"></param> /// <returns></returns> public static string ResolveUrl(string url) { if (url != null && url.StartsWith("~") && HttpContext.Current != null) { string appPath = HttpContext.Current.Request.ApplicationPath.Length > 1 ? HttpContext.Current.Request.ApplicationPath : string.Empty; url = appPath + url.Substring(1); } return url; } #endregion #region Static Methods for javascript writing /// <summary> /// Produces the javascript that redirects to a url. /// </summary> /// <param name="url"></param> public static void Redirect(string url) { Response.Clear(); Write(String.Format("window.location.href=\"{0}\";\r\n", ResolveUrl(url))); End(); } /// <summary> /// Produces the javascript that will set the attributes of a control. /// </summary> /// <remarks> /// The attributes must be of this format: /// "attrib1=value1|attrib2=value2|attrib3=value3" /// </remarks> /// <param name="clientID">ClientID of the control</param> /// <param name="attributes">Formatted list of attributes</param> public static void WriteSetAttributesOfControl(string clientID, string attributes) { Write( String.Format("AJAXCbo.SetAttributesOfControl(\"{0}\",\"{1}\");\r\n", clientID, attributes) ); } /// <summary> /// Produces the javascript that will a new element on the page. /// </summary> /// <param name="parentID">The id of the element that will contain the new element</param> /// <param name="elementID">The id of the new element</param> /// <param name="html">The innerHTML of the new element</param> /// <param name="beforeElemID">The id of the element that the new element must be inserted before it. Use null to append the new element at the end of the parent element</param> public static void WriteAddElementScript(string parentID, string tagName, string elementID, string html, string beforeElemID) { string before = (beforeElemID != null) ? String.Format("\"{0}\"", beforeElemID) : "null"; Write( String.Format("AJAXCbo.AddElementScript(\"{0}\",\"{1}\",\"{2}\",{3},{4});\r\n", parentID, tagName, elementID, EncodeString(html), before) ); } /// <summary> /// Provides the javascript that will remove an existing element from the page. /// </summary> /// <param name="parentID">The id of the element that contains the element to be removed</param> /// <param name="elementID">The id of the element to be removed</param> public static void WriteRemoveElementScript(string parentID, string elementID) { Write( String.Format("AJAXCbo.RemoveElementScript(\"{0}\",\"{1}\");\r\n", parentID, elementID) ); } /// <summary> /// Provides the javascript that will set the value of a field on the page. /// </summary> /// <remarks> /// Use this if you want to manipulate, during AjaxCall, a hidden field previously /// registered by the Page.RegisterHiddenField method. /// </remarks> /// <param name="fieldName"></param> /// <param name="fieldValue"></param> public static void WriteSetFieldScript(string fieldName, string fieldValue) { Write( String.Format("AJAXCbo.SetFieldScript(\"{0}\",{1});\r\n", fieldName, EncodeString(fieldValue)) ); } /// <summary> /// Provides the javascript that will se the innerHTML of an element of the page. /// </summary> /// <param name="html"></param> /// <param name="elementID">The id of the element of the page</param> public static void WriteSetHtmlOfElementScript(string html, string elementID) { Write( String.Format("AJAXCbo.SetHtmlOfElementScript({0},\"{1}\");\r\n", EncodeString(html), elementID) ); } public static void WriteSetHtmlOfPageScript(string html) { Write ( String.Format("AJAXCbo.SetHtmlOfPage({0});\r\n", EncodeString(html)) ); } public static void WriteSetVisibilityOfElementScript(string elementID, bool visible) { Write ( String.Format("AJAXCbo.SetVisibilityOfElement(\"{0}\",{1});\r\n", elementID ,visible.ToString().ToLower()) ); } /// <summary> /// Provides the javascript that will invoke an alert message box. /// </summary> /// <param name="message"></param> public static void WriteAlert(string message) { Write ( String.Format("AJAXCbo.Alert({0});\r\n", EncodeString(message)) ); } /// <summary> /// It appends a "'AJAX_LOADING_OK';" string to the end, so that the client /// knows that the loading of the AjaxCall javascript data wasn't aborted, /// but they were fully loaded. /// </summary> /// <remarks> /// Called by the End method. /// </remarks> internal static void WriteEndSignature() { Write ("'AJAX_LOADING_OK';"); } /// <summary> /// Converts a string to a javascript string. /// </summary> /// <example> /// AjaxCallHelper.Write (String.Format("alert({0});", AjaxCallHelper.EncodeString("Alert invoked by javascript."))); /// </example> /// <param name="str"></param> /// <returns></returns> public static string EncodeString(string str) { //TODO: use 1 regular expression (faster) System.Text.StringBuilder sb = new System.Text.StringBuilder(str); sb.Replace("\\", "\\\\"); sb.Replace("\"", "\\\""); sb.Replace("\r", "\\r"); sb.Replace("\n", "\\n"); sb.Replace("\t", "\\t"); sb.Insert(0, '\"'); sb.Append('\"'); return sb.ToString(); } /// <summary> /// Writes to the Response. Included for convenience. /// </summary> /// <remarks> /// Use this method if you want to send custom javascript code for the client to execute. /// Use EncodeString if you want to append a string for your javascript code. /// </remarks> /// <example> /// AjaxCallHelper.Write (String.Format("var span = document.getElementById('{0}');", label.ClientID)); /// AjaxCallHelper.Write (String.Format("span.innerHTML = {0});", AjaxCallHelper.EncodeString("Changed by javascript"))); /// </example> /// <param name="text"></param> public static void Write( string text) { // Use the string builder //Response.Write (text + "\r\n"); sbScript.Append (text + "\r\n"); } internal static void Init() { HttpResponse hr = AjaxCallHelper.Response; hr.StatusCode = 200; hr.StatusDescription = "OK"; sbScript = new System.Text.StringBuilder(); } /// <summary> /// Use this method instead of Response.End during an AjaxCall. /// </summary> /// <remarks> /// Writes the End signature, ends the writing to the Response and causes /// CompleteRequest on the application. /// </remarks> public static void End() { WriteEndSignature(); HttpResponse hr = AjaxCallHelper.Response; hr.Clear(); hr.Write (sbScript.ToString()); MagicAjaxModule.Instance.CompletedAjaxCall = true; hr.Flush(); hr.End(); } #endregion } } Index: Web.config =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Web.config,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Web.config 11 Nov 2005 06:17:49 -0000 1.1 --- Web.config 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 8,15 **** <!-- MagicAjax configuration : ! [Optional] callBackScriptPath - Alternative path for "CallBackObject.js" ! If omitted, the embedded "CallBackObject.js" file is used (default). ! example: <magicAjax callBackScriptPath="~/script" /> ! pageStore/mode - "NoStore" : Doesn't keep the page object, it is recreated for each callback "Session" : Saves the page object in session, works only for "InProc" SessionState "Cache" : Saves the page object in cache --- 8,15 ---- <!-- MagicAjax configuration : ! [Optional] ajaxCallScriptPath - Alternative path for "AjaxCallObject.js" ! If omitted, the embedded "AjaxCallObject.js" file is used (default). ! example: <magicAjax ajaxCallScriptPath="~/script" /> ! pageStore/mode - "NoStore" : Doesn't keep the page object, it is recreated for each AjaxCall "Session" : Saves the page object in session, works only for "InProc" SessionState "Cache" : Saves the page object in cache Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MagicAjaxModule.cs 14 Nov 2005 16:16:56 -0000 1.4 --- MagicAjaxModule.cs 14 Nov 2005 18:50:43 -0000 1.5 *************** *** 38,42 **** { /// <summary> ! /// It handles a CallBack request from the client and sends the appropriate javascript. /// </summary> /// <remarks> --- 38,42 ---- { /// <summary> ! /// It handles an AjaxCall request from the client and sends the appropriate javascript. /// </summary> /// <remarks> *************** *** 69,76 **** #endregion ! private bool _isCallBack = false; private NameValueCollection _form; private MagicAjaxConfiguration _config; ! private bool _completedCallBack; private PageFilter _filter; private HttpContext _context; --- 69,76 ---- #endregion ! private bool _isAjaxCall = false; private NameValueCollection _form; private MagicAjaxConfiguration _config; ! private bool _completedAjaxCall; private PageFilter _filter; private HttpContext _context; *************** *** 80,86 **** #region Properties ! public bool IsCallBack { ! get { return _isCallBack; } } --- 80,86 ---- #region Properties ! public bool IsAjaxCall { ! get { return _isAjaxCall; } } *************** *** 95,102 **** } ! public bool CompletedCallBack { ! get { return _completedCallBack; } ! set { _completedCallBack = value; } } #endregion --- 95,102 ---- } ! public bool CompletedAjaxCall { ! get { return _completedAjaxCall; } ! set { _completedAjaxCall = value; } } #endregion *************** *** 133,151 **** /// This method is called by controls that inherit from AjaxControl. /// Depending on the configuration options of MagicAjax, the page object may ! /// be stored so that MagicAjaxModule can retrieve it at a CallBack. /// </remarks> public virtual void EnableAjaxOnPage(Page page) { ! if ( _isCallBack ) return; string STARTUP_SCRIPT_FORMAT = @" <script language='javascript'> if (typeof(AJAXCbo) == 'undefined') ! alert(""Unable to find script library '{0}/{1}'. Copy the file to the required location, or change the 'callBackScriptPath' setting at magicAjax section of web.config.""); else ! AJAXCbo.HookCallBack({2}); </script>"; ! if (!page.IsClientScriptBlockRegistered( "CALLBACK_FOR_AJAX" )) { // Provides the location of the script file. --- 133,151 ---- /// This method is called by controls that inherit from AjaxControl. /// Depending on the configuration options of MagicAjax, the page object may ! /// be stored so that MagicAjaxModule can retrieve it at an AjaxCall. /// </remarks> public virtual void EnableAjaxOnPage(Page page) { ! if ( _isAjaxCall ) return; string STARTUP_SCRIPT_FORMAT = @" <script language='javascript'> if (typeof(AJAXCbo) == 'undefined') ! alert(""Unable to find script library '{0}/{1}'. Copy the file to the required location, or change the 'ajaxCallScriptPath' setting at magicAjax section of web.config.""); else ! AJAXCbo.HookAjaxCall({2}); </script>"; ! if (!page.IsClientScriptBlockRegistered( "AJAXCALL_FOR_MAGICAJAX" )) { // Provides the location of the script file. *************** *** 153,165 **** string includeScript; ! // If script location is null, use embedded CallBackObject.js file if (location == null) { #if NET_2_0 ! //use the webresource url for CallBackObject.js ! includeScript = String.Format("<script type=\"text/javascript\" src=\"{0}\"></script>", page.ClientScript.GetWebResourceUrl(typeof(MagicAjaxModule), "MagicAjax.script.CallBackObject.js")); #else ! //read and output the embedded CallBackObject.js file from the manifest ! using (System.IO.StreamReader reader = new System.IO.StreamReader(typeof(MagicAjaxModule).Assembly.GetManifestResourceStream("MagicAjax.script.CallBackObject.js"))) { includeScript = String.Format("<script type=\"text/javascript\">\r\n<!--\r\n{0}\r\n//-->\r\n</script>", reader.ReadToEnd()); --- 153,165 ---- string includeScript; ! // If script location is null, use embedded AjaxCallObject.js file if (location == null) { #if NET_2_0 ! //use the webresource url for AjaxCallObject.js ! includeScript = String.Format("<script type=\"text/javascript\" src=\"{0}\"></script>", page.ClientScript.GetWebResourceUrl(typeof(MagicAjaxModule), "MagicAjax.script.AjaxCallObject.js")); #else ! //read and output the embedded AjaxCallObject.js file from the manifest ! using (System.IO.StreamReader reader = new System.IO.StreamReader(typeof(MagicAjaxModule).Assembly.GetManifestResourceStream("MagicAjax.script.AjaxCallObject.js"))) { includeScript = String.Format("<script type=\"text/javascript\">\r\n<!--\r\n{0}\r\n//-->\r\n</script>", reader.ReadToEnd()); *************** *** 170,179 **** { // Point to external script source file ! includeScript = String.Format("<script type=\"text/javascript\" src=\"{0}/{1}\"></script>", location, "CallBackObject.js"); } ! page.RegisterClientScriptBlock( "CALLBACK_FOR_AJAX", includeScript ); bool pageIsStored = (_config.PageStore.Mode != PageStoreMode.NoStore); ! page.RegisterStartupScript( "CALLBACK_HOOK", String.Format(STARTUP_SCRIPT_FORMAT, location, "CallBackObject.js", pageIsStored.ToString().ToLower())); if ( pageIsStored ) --- 170,179 ---- { // Point to external script source file ! includeScript = String.Format("<script type=\"text/javascript\" src=\"{0}/{1}\"></script>", location, "AjaxCallObject.js"); } ! page.RegisterClientScriptBlock( "AJAXCALL_FOR_MAGICAJAX", includeScript ); bool pageIsStored = (_config.PageStore.Mode != PageStoreMode.NoStore); ! page.RegisterStartupScript( "AJAXCALL_HOOK", String.Format(STARTUP_SCRIPT_FORMAT, location, "AjaxCallObject.js", pageIsStored.ToString().ToLower())); if ( pageIsStored ) *************** *** 321,325 **** // Firefox requests the page first and then sends the unload page request, // so check to see if the page we are going to remove is just created. ! if (storedInfo.CallBacksCount == 0 && DateTime.Now-storedInfo.LastAccess < TimeSpan.FromSeconds(5)) return; --- 321,325 ---- // Firefox requests the page first and then sends the unload page request, // so check to see if the page we are going to remove is just created. ! if (storedInfo.AjaxCallsCount == 0 && DateTime.Now-storedInfo.LastAccess < TimeSpan.FromSeconds(5)) return; *************** *** 399,404 **** } ! _isCallBack = false; ! _completedCallBack = false; Page requestPage = (Page) _context.Handler; --- 399,404 ---- } ! _isAjaxCall = false; ! _completedAjaxCall = false; Page requestPage = (Page) _context.Handler; *************** *** 409,427 **** #endif ! // Continue only if it is a postback or a callback if ( "GET" == _request.HttpMethod ) return; ! _isCallBack = (_request.Form["__AJAX_CALLBACK"] != null); _form = _request.Form; if ( PageStoreMode.NoStore == _config.PageStore.Mode ) { ! if ( _isCallBack ) { _filter = new PageFilter(_response.Filter); _response.Filter = _filter; ! CallBackHelper.Init(); _context.Handler.ProcessRequest (_context); --- 409,427 ---- #endif ! // Continue only if it is a postback or an AjaxCall if ( "GET" == _request.HttpMethod ) return; ! _isAjaxCall = (_request.Form["__AJAXCALL"] != null); _form = _request.Form; if ( PageStoreMode.NoStore == _config.PageStore.Mode ) { ! if ( _isAjaxCall ) { _filter = new PageFilter(_response.Filter); _response.Filter = _filter; ! AjaxCallHelper.Init(); _context.Handler.ProcessRequest (_context); *************** *** 431,435 **** if (vsValue != null && _form["__VIEWSTATE"] != vsValue) { ! CallBackHelper.WriteSetFieldScript("__VIEWSTATE", vsValue); } --- 431,435 ---- if (vsValue != null && _form["__VIEWSTATE"] != vsValue) { ! AjaxCallHelper.WriteSetFieldScript("__VIEWSTATE", vsValue); } *************** *** 480,491 **** __wpm.zones = new Array(); }"; ! CallBackHelper.Write(wpm_Dispose_script); // Send script to setup webpartmanager drag&drop + webpartmenu's ! CallBackHelper.Write(wpmValue); } } #endif ! CallBackHelper.End(); } } --- 480,491 ---- __wpm.zones = new Array(); }"; ! AjaxCallHelper.Write(wpm_Dispose_script); // Send script to setup webpartmanager drag&drop + webpartmenu's ! AjaxCallHelper.Write(wpmValue); } } #endif ! AjaxCallHelper.End(); } } *************** *** 498,502 **** if (pageKey == null) { ! if ( _isCallBack ) throw new MagicAjaxException(String.Format("Hidden field '{0}' wasn't found. Page isn't AJAX enabled.", PageKeyFieldName)); else --- 498,502 ---- if (pageKey == null) { ! if ( _isAjaxCall ) throw new MagicAjaxException(String.Format("Hidden field '{0}' wasn't found. Page isn't AJAX enabled.", PageKeyFieldName)); else *************** *** 510,517 **** // Have the browser do a refresh. // It will stop the current execution and will throw Application_EndRequest event ! CallBackHelper.Redirect (_request.RawUrl); } ! if ( ! _isCallBack ) { // PostBack. Will replace the recreated controls with the stored ones --- 510,517 ---- // Have the browser do a refresh. // It will stop the current execution and will throw Application_EndRequest event ! AjaxCallHelper.Redirect (_request.RawUrl); } ! if ( ! _isAjaxCall ) { // PostBack. Will replace the recreated controls with the stored ones *************** *** 520,529 **** else { ! // CallBack _filter = new PageFilter(_response.Filter); _response.Filter = _filter; ! if (_currentPageInfo.CallBacksCount == 0 && _currentPageInfo.Page.Validators.Count == 0) { --- 520,529 ---- else { ! // AjaxCall _filter = new PageFilter(_response.Filter); _response.Filter = _filter; ! if (_currentPageInfo.AjaxCallsCount == 0 && _currentPageInfo.Page.Validators.Count == 0) { *************** *** 534,545 **** } ! CallBackHelper.Init(); ! ProcessCallBack(_currentPageInfo.Page); ! _currentPageInfo.CallBacksCount++; _currentPageInfo.LastAccess = DateTime.Now; ! CallBackHelper.End(); } } --- 534,545 ---- } ! AjaxCallHelper.Init(); ! ProcessAjaxCall(_currentPageInfo.Page); ! _currentPageInfo.AjaxCallsCount++; _currentPageInfo.LastAccess = DateTime.Now; ! AjaxCallHelper.End(); } } *************** *** 559,563 **** /// </summary> /// <remarks> ! /// During a callback it checks if the request was ended because of a /// Response.Redirect or a Server.Transfer and sends the appropriate javascript /// for each case. --- 559,563 ---- /// </summary> /// <remarks> ! /// During an AjaxCall it checks if the request was ended because of a /// Response.Redirect or a Server.Transfer and sends the appropriate javascript /// for each case. *************** *** 567,574 **** protected virtual void Application_EndRequest(object sender, EventArgs e) { ! if ( ! _isCallBack || _completedCallBack ) return; ! // There was a Response.Redirect or Server.Transfer during callback HttpApplication application = (HttpApplication) sender; --- 567,574 ---- protected virtual void Application_EndRequest(object sender, EventArgs e) { ! if ( ! _isAjaxCall || _completedAjaxCall ) return; ! // There was a Response.Redirect or Server.Transfer during AjaxCall HttpApplication application = (HttpApplication) sender; *************** *** 578,599 **** { // Handle Response.Redirect ! CallBackHelper.Redirect (response.RedirectLocation); } else { // Handle Server.Transfer ! CallBackHelper.Init(); string html = _filter.GetHtmlPage(); ! CallBackHelper.WriteSetHtmlOfPageScript (html); ! CallBackHelper.End(); } } /// <summary> ! /// Raises the callback events on the Page and the child controls, /// and invokes the IScriptWriter controls. /// </summary> /// <param name="page"></param> ! protected virtual void ProcessCallBack(Page page) { ReadOnlyArrayList postDataChangedControls; --- 578,599 ---- { // Handle Response.Redirect ! AjaxCallHelper.Redirect (response.RedirectLocation); } else { // Handle Server.Transfer ! AjaxCallHelper.Init(); string html = _filter.GetHtmlPage(); ! AjaxCallHelper.WriteSetHtmlOfPageScript (html); ! AjaxCallHelper.End(); } } /// <summary> ! /// Raises the AjaxCall events on the Page and the child controls, /// and invokes the IScriptWriter controls. /// </summary> /// <param name="page"></param> ! protected virtual void ProcessAjaxCall(Page page) { ReadOnlyArrayList postDataChangedControls; *************** *** 605,611 **** handler.RaisePostDataChangedEvent(); ! RaiseCallBackEvent (page); ! if ( CallBackHelper.CallBackType == CallBackType.Control ) { string target = _form["__EVENTTARGET"]; --- 605,611 ---- handler.RaisePostDataChangedEvent(); ! RaiseAjaxCallEvent (page); ! if ( AjaxCallHelper.AjaxCallType == AjaxCallType.Control ) { string target = _form["__EVENTTARGET"]; *************** *** 638,656 **** /// <summary> ! /// Raises callback event on the supplied control and its children. /// </summary> /// <remarks> /// This is a recursive method. It goes through the control collection tree ! /// and raises the callback event on all the controls that implement the ! /// ICallBackEventHandler interface. /// </remarks> /// <param name="control"></param> ! protected virtual void RaiseCallBackEvent (Control control) { ! if (control is ICallBackEventHandler) ! ((ICallBackEventHandler) control).RaiseCallBackEvent(); for (int i=0; i < control.Controls.Count; i++) ! RaiseCallBackEvent (control.Controls[i]); } --- 638,656 ---- /// <summary> ! /// Raises AjaxCall event on the supplied control and its children. /// </summary> /// <remarks> /// This is a recursive method. It goes through the control collection tree ! /// and raises the AjaxCall event on all the controls that implement the ! /// IAjaxCallEventHandler interface. /// </remarks> /// <param name="control"></param> ! protected virtual void RaiseAjaxCallEvent (Control control) { ! if (control is IAjaxCallEventHandler) ! ((IAjaxCallEventHandler) control).RaiseAjaxCallEvent(); for (int i=0; i < control.Controls.Count; i++) ! RaiseAjaxCallEvent (control.Controls[i]); } *************** *** 692,696 **** /// <summary> ! /// Loads form post data on controls during a CallBack. /// </summary> protected virtual ArrayList LoadFormDataOnChildren (Control control) --- 692,696 ---- /// <summary> ! /// Loads form post data on controls during an AjaxCall. /// </summary> protected virtual ArrayList LoadFormDataOnChildren (Control control) *************** *** 717,721 **** // For some strange reason, if the RadioButtonList selection // changes, the SelectedIndexChanged event is invoked every time ! // a callback occurs. So, do a manual check. RadioButtonList rbList = (RadioButtonList) con; if (_form[rbList.UniqueID] != rbList.SelectedValue) --- 717,721 ---- // For some strange reason, if the RadioButtonList selection // changes, the SelectedIndexChanged event is invoked every time ! // an AjaxCall occurs. So, do a manual check. RadioButtonList rbList = (RadioButtonList) con; if (_form[rbList.UniqueID] != rbList.SelectedValue) *************** *** 757,761 **** /// <summary> ! /// Raises a PostBack event of a control during a CallBack. /// </summary> /// <param name="eventTarget"></param> --- 757,761 ---- /// <summary> ! /// Raises a PostBack event of a control during an AjaxCall. /// </summary> /// <param name="eventTarget"></param> *************** *** 802,806 **** /// <summary> ! /// Used to store and retrieve the html rendering of the page during a callback /// </summary> private class PageFilter : Stream --- 802,806 ---- /// <summary> ! /// Used to store and retrieve the html rendering of the page during an AjaxCall /// </summary> private class PageFilter : Stream *************** *** 865,869 **** string elmID = matchDragElm.Groups["DragElmId"].Value; wpmScript.AppendLine(string.Format("if (document.getElementById('{0}') == null)", elmID)); ! wpmScript.AppendLine(string.Format(" AJAXCbo.AddElementScript('{0}','span','__DragHolder',{1},'null');", formID, CallBackHelper.EncodeString(matchDragElm.Value))); } --- 865,869 ---- string elmID = matchDragElm.Groups["DragElmId"].Value; wpmScript.AppendLine(string.Format("if (document.getElementById('{0}') == null)", elmID)); ! wpmScript.AppendLine(string.Format(" AJAXCbo.AddElementScript('{0}','span','__DragHolder',{1},'null');", formID, AjaxCallHelper.EncodeString(matchDragElm.Value))); } *************** *** 953,961 **** public override void Write(byte[] buffer, int offset, int count) { ! if ( CallBackHelper.IsCallBack ) { _memStream.Write (buffer, offset, count); ! if ( MagicAjaxModule.Instance.CompletedCallBack ) _responseStream.Write (buffer, offset, count); } --- 953,961 ---- public override void Write(byte[] buffer, int offset, int count) { ! if ( AjaxCallHelper.IsAjaxCall ) { _memStream.Write (buffer, offset, count); ! if ( MagicAjaxModule.Instance.CompletedAjaxCall ) _responseStream.Write (buffer, offset, count); } |
From: Argiris K. <be...@us...> - 2005-11-14 18:50:55
|
Update of /cvsroot/magicajax/magicajax/Core/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30932/Core/UI Modified Files: AjaxControl.cs AjaxPage.cs AjaxUserControl.cs RenderedByScriptControl.cs Log Message: Replaced all "CallBack" references by "AjaxCall" Index: AjaxUserControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxUserControl.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AjaxUserControl.cs 11 Nov 2005 06:17:49 -0000 1.1 --- AjaxUserControl.cs 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 26,51 **** { /// <summary> ! /// Includes the CallBack event, Context, Request and Response, for convenience. /// </summary> /// <remarks> ! /// You can implement the ICallBackEventHandler on your usercontrol to handle the ! /// CallBack event, and use the HttpContext.Current, CallBackHelper.Request and ! /// CallBackHelper.Response properties. /// /// You cannot use the Context, Request and Response of the System.Web.UI.UserControl ! /// because, during a CallBack, the Context of the page is invalid. If you don't want /// to replace the UserControl.Request and UserControl.Response from your code for ! /// CallBackHelper.Request and CallBackHelper.Response, and your usercontrol is inherited /// from System.Web.UI.UserControl, you can use AjaxUserControl for convenience. /// </remarks> ! public class AjaxUserControl : System.Web.UI.UserControl, ICallBackEventHandler { /// <summary> ! /// Raised by MagicAjaxModule when a CallBack occurs /// </summary> ! public event EventHandler CallBack; /// <summary> ! /// The base UserControl Request property doesn't work during a CallBack. Use this instead. /// </summary> public new HttpRequest Request --- 26,51 ---- { /// <summary> ! /// Includes the AjaxCall event, Context, Request and Response, for convenience. /// </summary> /// <remarks> ! /// You can implement the IAjaxCallEventHandler on your usercontrol to handle the ! /// AjaxCall event, and use the HttpContext.Current, AjaxCallHelper.Request and ! /// AjaxCallHelper.Response properties. /// /// You cannot use the Context, Request and Response of the System.Web.UI.UserControl ! /// because, during an AjaxCall, the Context of the page is invalid. If you don't want /// to replace the UserControl.Request and UserControl.Response from your code for ! /// AjaxCallHelper.Request and AjaxCallHelper.Response, and your usercontrol is inherited /// from System.Web.UI.UserControl, you can use AjaxUserControl for convenience. /// </remarks> ! public class AjaxUserControl : System.Web.UI.UserControl, IAjaxCallEventHandler { /// <summary> ! /// Raised by MagicAjaxModule when an AjaxCall occurs /// </summary> ! public event EventHandler AjaxCall; /// <summary> ! /// The base UserControl Request property doesn't work during an AjaxCall. Use this instead. /// </summary> public new HttpRequest Request *************** *** 58,62 **** /// <summary> ! /// The base UserControl Response property doesn't work during a CallBack. Use this instead. /// </summary> public new HttpResponse Response --- 58,62 ---- /// <summary> ! /// The base UserControl Response property doesn't work during an AjaxCall. Use this instead. /// </summary> public new HttpResponse Response *************** *** 69,80 **** /// <summary> ! /// Raises the CallBack event. /// </summary> /// <remarks> /// Called by MagicAjaxModule. /// </remarks> ! public void RaiseCallBackEvent() { ! OnCallBack (EventArgs.Empty); } --- 69,80 ---- /// <summary> ! /// Raises the AjaxCall event. /// </summary> /// <remarks> /// Called by MagicAjaxModule. /// </remarks> ! public void RaiseAjaxCallEvent() { ! OnAjaxCall (EventArgs.Empty); } *************** *** 87,94 **** } ! protected virtual void OnCallBack(EventArgs e) { ! if (CallBack != null) ! CallBack(this, e); } } --- 87,94 ---- } ! protected virtual void OnAjaxCall(EventArgs e) { ! if (AjaxCall != null) ! AjaxCall(this, e); } } Index: AjaxPage.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxPage.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AjaxPage.cs 11 Nov 2005 06:17:49 -0000 1.1 --- AjaxPage.cs 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 26,52 **** { /// <summary> ! /// Includes the CallBack event, Context, Request and Response, for convenience. /// </summary> /// <remarks> /// Inhering from AjaxPage is not required to apply AJAX on your pages. You can ! /// implement the ICallBackEventHandler on your page to handle the CallBack event, and ! /// use the HttpContext.Current, CallBackHelper.Request and CallBackHelper.Response /// properties. /// /// You cannot use the Context, Request and Response of the System.Web.UI.Page ! /// because, during a CallBack, the Context of the page is invalid. If you don't want /// to replace the Page.Request and Page.Response from your code for ! /// CallBackHelper.Request and CallBackHelper.Response, and your page is inherited /// from System.Web.UI.Page, you can use AjaxPage for convenience. /// </remarks> ! public class AjaxPage : System.Web.UI.Page, ICallBackEventHandler { /// <summary> ! /// Raised by MagicAjaxModule when a CallBack occurs /// </summary> ! public event EventHandler CallBack; /// <summary> ! /// The base Page Request property doesn't work during a CallBack. Use this instead. /// </summary> public new HttpRequest Request --- 26,52 ---- { /// <summary> ! /// Includes the AjaxCall event, Context, Request and Response, for convenience. /// </summary> /// <remarks> /// Inhering from AjaxPage is not required to apply AJAX on your pages. You can ! /// implement the IAjaxCallEventHandler on your page to handle the AjaxCall event, and ! /// use the HttpContext.Current, AjaxCallHelper.Request and AjaxCallHelper.Response /// properties. /// /// You cannot use the Context, Request and Response of the System.Web.UI.Page ! /// because, during an AjaxCall, the Context of the page is invalid. If you don't want /// to replace the Page.Request and Page.Response from your code for ! /// AjaxCallHelper.Request and AjaxCallHelper.Response, and your page is inherited /// from System.Web.UI.Page, you can use AjaxPage for convenience. /// </remarks> ! public class AjaxPage : System.Web.UI.Page, IAjaxCallEventHandler { /// <summary> ! /// Raised by MagicAjaxModule when an AjaxCall occurs /// </summary> ! public event EventHandler AjaxCall; /// <summary> ! /// The base Page Request property doesn't work during an AjaxCall. Use this instead. /// </summary> public new HttpRequest Request *************** *** 59,63 **** /// <summary> ! /// The base Page Response property doesn't work during a CallBack. Use this instead. /// </summary> public new HttpResponse Response --- 59,63 ---- /// <summary> ! /// The base Page Response property doesn't work during an AjaxCall. Use this instead. /// </summary> public new HttpResponse Response *************** *** 70,81 **** /// <summary> ! /// Raises the CallBack event. /// </summary> /// <remarks> /// Called by MagicAjaxModule. /// </remarks> ! public void RaiseCallBackEvent() { ! OnCallBack (EventArgs.Empty); } --- 70,81 ---- /// <summary> ! /// Raises the AjaxCall event. /// </summary> /// <remarks> /// Called by MagicAjaxModule. /// </remarks> ! public void RaiseAjaxCallEvent() { ! OnAjaxCall (EventArgs.Empty); } *************** *** 88,95 **** } ! protected virtual void OnCallBack(EventArgs e) { ! if (CallBack != null) ! CallBack(this, e); } } --- 88,95 ---- } ! protected virtual void OnAjaxCall(EventArgs e) { ! if (AjaxCall != null) ! AjaxCall(this, e); } } Index: AjaxControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxControl.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AjaxControl.cs 11 Nov 2005 06:17:49 -0000 1.1 --- AjaxControl.cs 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 28,46 **** { /// <summary> ! /// The base control for controls to get notified for callback events from the client. /// </summary> ! public class AjaxControl : System.Web.UI.WebControls.WebControl, ICallBackEventHandler { /// <summary> /// Raised by the MagicAjaxModule. /// </summary> ! public event EventHandler CallBack; /// <summary> ! /// Implements the ICallBackEventHandler interface. It is called by the MagicAjaxModule. /// </summary> ! public void RaiseCallBackEvent() { ! OnCallBack(EventArgs.Empty); } --- 28,46 ---- { /// <summary> ! /// The base control for controls to get notified for AjaxCall events from the client. /// </summary> ! public class AjaxControl : System.Web.UI.WebControls.WebControl, IAjaxCallEventHandler { /// <summary> /// Raised by the MagicAjaxModule. /// </summary> ! public event EventHandler AjaxCall; /// <summary> ! /// Implements the IAjaxCallEventHandler interface. It is called by the MagicAjaxModule. /// </summary> ! public void RaiseAjaxCallEvent() { ! OnAjaxCall(EventArgs.Empty); } *************** *** 59,71 **** protected override void OnPreRender(EventArgs e) { ! // Register 'CallBackObject.js' script MagicAjaxModule.Instance.EnableAjaxOnPage(this.Page); base.OnPreRender (e); } ! protected virtual void OnCallBack(EventArgs e) { ! if (CallBack != null) ! CallBack(this, e); } } --- 59,71 ---- protected override void OnPreRender(EventArgs e) { ! // Register 'AjaxCallObject.js' script MagicAjaxModule.Instance.EnableAjaxOnPage(this.Page); base.OnPreRender (e); } ! protected virtual void OnAjaxCall(EventArgs e) { ! if (AjaxCall != null) ! AjaxCall(this, e); } } Index: RenderedByScriptControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/RenderedByScriptControl.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RenderedByScriptControl.cs 11 Nov 2005 06:17:49 -0000 1.1 --- RenderedByScriptControl.cs 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 62,66 **** /// <summary> /// This control manages its appearance on the page using javascript that sends ! /// to the client during a CallBack. /// </summary> /// <remarks> --- 62,66 ---- /// <summary> /// This control manages its appearance on the page using javascript that sends ! /// to the client during an AjaxCall. /// </summary> /// <remarks> *************** *** 89,97 **** set { ! if ( CallBackHelper.IsCallBack && IsRenderedOnPage && MonitorVisibilityState && value != base.Visible ) ! CallBackHelper.WriteSetVisibilityOfElementScript (ClientID, value); base.Visible = value; --- 89,97 ---- set { ! if ( AjaxCallHelper.IsAjaxCall && IsRenderedOnPage && MonitorVisibilityState && value != base.Visible ) ! AjaxCallHelper.WriteSetVisibilityOfElementScript (ClientID, value); base.Visible = value; *************** *** 116,126 **** /// <summary> /// Gets or sets whether every time "Visible" property is changed ! /// CallBackHelper.WriteSetVisibilityOfElementScript method should be called. /// Default is true. /// </summary> /// <remarks> /// If this property is true, every time you change the "Visible" property during a ! /// CallBack, the display attribute of the style of the control on the page will ! /// be set to "" or "none" by calling the CallBackHelper.WriteSetVisibilityOfElementScript /// method. /// </remarks> --- 116,126 ---- /// <summary> /// Gets or sets whether every time "Visible" property is changed ! /// AjaxCallHelper.WriteSetVisibilityOfElementScript method should be called. /// Default is true. /// </summary> /// <remarks> /// If this property is true, every time you change the "Visible" property during a ! /// AjaxCall, the display attribute of the style of the control on the page will ! /// be set to "" or "none" by calling the AjaxCallHelper.WriteSetVisibilityOfElementScript /// method. /// </remarks> *************** *** 156,160 **** /// <remarks> /// The RenderedByScriptControl can be normally rendered by the Render method ! /// even during a CallBack (i.e when all the controls of an AjaxPanel is new /// and the AjaxPanel renders all of them in a single html rendering). /// In this case it's not necessary to send any javascript to the client. --- 156,160 ---- /// <remarks> /// The RenderedByScriptControl can be normally rendered by the Render method ! /// even during an AjaxCall (i.e when all the controls of an AjaxPanel is new /// and the AjaxPanel renders all of them in a single html rendering). /// In this case it's not necessary to send any javascript to the client. *************** *** 165,172 **** } ! protected override void OnCallBack(EventArgs e) { _isHtmlRendered = false; ! base.OnCallBack(e); } --- 165,172 ---- } ! protected override void OnAjaxCall(EventArgs e) { _isHtmlRendered = false; ! base.OnAjaxCall(e); } *************** *** 273,277 **** { Control con = FindNextVisibleSibling(); ! CallBackHelper.WriteAddElementScript (Parent.ClientID, this.GetTagName(), this.ClientID, "", (con == null) ? null : con.ClientID); } --- 273,277 ---- { Control con = FindNextVisibleSibling(); ! AjaxCallHelper.WriteAddElementScript (Parent.ClientID, this.GetTagName(), this.ClientID, "", (con == null) ? null : con.ClientID); } *************** *** 287,291 **** if(_currentTagHtml != html) { ! CallBackHelper.WriteSetAttributesOfControl (ClientID, FormatAttributes(html)); _currentTagHtml = html; } --- 287,291 ---- if(_currentTagHtml != html) { ! AjaxCallHelper.WriteSetAttributesOfControl (ClientID, FormatAttributes(html)); _currentTagHtml = html; } *************** *** 334,338 **** /// <summary> /// It finds the attributes from the html of the control's tag, and formats them ! /// so that they are send by CallBackHelper.WriteSetAttributesOfControl method. /// </summary> /// <param name="html">The html tag of the control</param> --- 334,338 ---- /// <summary> /// It finds the attributes from the html of the control's tag, and formats them ! /// so that they are send by AjaxCallHelper.WriteSetAttributesOfControl method. /// </summary> /// <param name="html">The html tag of the control</param> |
From: Argiris K. <be...@us...> - 2005-11-14 18:50:55
|
Update of /cvsroot/magicajax/magicajax/Core/Interfaces In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30932/Core/Interfaces Modified Files: IFormDataLoadedEventHandler.cs IScriptWriter.cs Added Files: IAjaxCallEventHandler.cs Log Message: Replaced all "CallBack" references by "AjaxCall" --- NEW FILE: IAjaxCallEventHandler.cs --- #region LGPL License /* MagicAjax Library Copyright (C) 2005 MagicAjax Project Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; namespace MagicAjax { /// <summary> /// Interface for controls that do no inherit from AjaxControl and want to receive /// AjaxCall events. /// </summary> /// <remarks> /// The Load event of the page and its child controls is not raised during an AjaxCall. /// If you want to handle the AjaxCall event instead, implement the IAjaxCallEventHandler /// on the page or on a cuatom control. /// </remarks> /// <example> /// public class CustomTextBox : System.Web.UI.WebControls.TextBox, IAjaxCallEventHandler /// { /// public void RaiseAjaxCallEvent() /// { /// OnAjaxCall(EventArgs.Empty); /// } /// } /// </example> public interface IAjaxCallEventHandler { void RaiseAjaxCallEvent(); } } Index: IFormDataLoadedEventHandler.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Interfaces/IFormDataLoadedEventHandler.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IFormDataLoadedEventHandler.cs 11 Nov 2005 06:17:49 -0000 1.1 --- IFormDataLoadedEventHandler.cs 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 30,34 **** /// <remarks> /// The PostDataLoadedEvent is raised by MagicAjaxModule after it loads the post data ! /// to the controls of the page, and before it raises the CallBack event. The event /// handler should not alter any IPostBackDataHandler controls because it may /// interfere with the functionality of other IFormDataLoadedEventHandler handlers. --- 30,34 ---- /// <remarks> /// The PostDataLoadedEvent is raised by MagicAjaxModule after it loads the post data ! /// to the controls of the page, and before it raises the AjaxCall event. The event /// handler should not alter any IPostBackDataHandler controls because it may /// interfere with the functionality of other IFormDataLoadedEventHandler handlers. Index: IScriptWriter.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Interfaces/IScriptWriter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IScriptWriter.cs 11 Nov 2005 06:17:49 -0000 1.1 --- IScriptWriter.cs 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 30,34 **** /// <remarks> /// WriteScript is called by MagicAjaxModule. A control that implements this method ! /// must use CallBackHelper.Write and the rest Write methods to send javascript /// code to the client. public interface IScriptWriter --- 30,34 ---- /// <remarks> /// WriteScript is called by MagicAjaxModule. A control that implements this method ! /// must use AjaxCallHelper.Write and the rest Write methods to send javascript /// code to the client. public interface IScriptWriter |
From: Argiris K. <be...@us...> - 2005-11-14 18:50:55
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30932/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Replaced all "CallBack" references by "AjaxCall" Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AjaxPanel.cs 11 Nov 2005 06:17:49 -0000 1.1 --- AjaxPanel.cs 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 31,48 **** { /// <summary> ! /// Defines the CallBack connection types. /// </summary> ! public enum CallBackConnectionType { /// <summary> ! /// Client will not invoke a CallBack /// </summary> None, /// <summary> ! /// Asynchronous CallBack /// </summary> Asynchronous, /// <summary> ! /// Synchronous CallBack /// </summary> Synchronous --- 31,48 ---- { /// <summary> ! /// Defines the AjaxCall connection types. /// </summary> ! public enum AjaxCallConnectionType { /// <summary> ! /// Client will not invoke an AjaxCall /// </summary> None, /// <summary> ! /// Asynchronous AjaxCall /// </summary> Asynchronous, /// <summary> ! /// Synchronous AjaxCall /// </summary> Synchronous *************** *** 64,68 **** /// rendering of the child-AjaxPanel, but instead the child-AjaxPanel will send only /// the html of the altered control. Thus, the size of javascript code that the client ! /// gets as a response of a callback, is greatly reduced. /// /// It is not necessary to put all the controls of the page inside an AjaxPanel. Only --- 64,68 ---- /// rendering of the child-AjaxPanel, but instead the child-AjaxPanel will send only /// the html of the altered control. Thus, the size of javascript code that the client ! /// gets as a response of an AjaxCall, is greatly reduced. /// /// It is not necessary to put all the controls of the page inside an AjaxPanel. Only *************** *** 78,82 **** #region Fields ! private CallBackConnectionType _callBackConnection = CallBackConnectionType.Asynchronous; private ArrayList _addedControls = new ArrayList(); private ArrayList _removedControls = new ArrayList(); --- 78,82 ---- #region Fields ! private AjaxCallConnectionType _ajaxCallConnection = AjaxCallConnectionType.Asynchronous; private ArrayList _addedControls = new ArrayList(); private ArrayList _removedControls = new ArrayList(); *************** *** 102,132 **** #region Properties ! #region CallBackConnection /// <summary> ! /// Defines the connection type (a/synchronous) that will be utilized for a CallBack. ! /// Default is CallBackConnectionType.Asynchronous. /// </summary> ! public CallBackConnectionType CallBackConnection { get { ! return _callBackConnection; } set { ! _callBackConnection = value; ! switch (_callBackConnection) { ! case CallBackConnectionType.None: ! this.Attributes.Remove ("CallBack"); break; ! case CallBackConnectionType.Asynchronous: ! this.Attributes["CallBack"] = "async"; break; ! case CallBackConnectionType.Synchronous: ! this.Attributes["CallBack"] = "sync"; break; } --- 102,132 ---- #region Properties ! #region AjaxCallConnection /// <summary> ! /// Defines the connection type (a/synchronous) that will be utilized for an AjaxCall. ! /// Default is AjaxCallConnectionType.Asynchronous. /// </summary> ! public AjaxCallConnectionType AjaxCallConnection { get { ! return _ajaxCallConnection; } set { ! _ajaxCallConnection = value; ! switch (_ajaxCallConnection) { ! case AjaxCallConnectionType.None: ! this.Attributes.Remove ("AjaxCall"); break; ! case AjaxCallConnectionType.Asynchronous: ! this.Attributes["AjaxCall"] = "async"; break; ! case AjaxCallConnectionType.Synchronous: ! this.Attributes["AjaxCall"] = "sync"; break; } *************** *** 217,224 **** _noVerifyPage.EnableValidation = (Page.Validators.Count > 0); ! if (this.Attributes["CallBack"] == null) { ! // To set the appropriate "CallBack" attribute. ! this.CallBackConnection = this._callBackConnection; } } --- 217,224 ---- _noVerifyPage.EnableValidation = (Page.Validators.Count > 0); ! if (this.Attributes["AjaxCall"] == null) { ! // To set the appropriate "AjaxCall" attribute. ! this.AjaxCallConnection = this._ajaxCallConnection; } } *************** *** 266,270 **** protected override void RenderChildren(HtmlTextWriter writer) { ! if ( CallBackHelper.IsCallBack && IsPageNoStoreMode ) { LoadControlState(); --- 266,270 ---- protected override void RenderChildren(HtmlTextWriter writer) { ! if ( AjaxCallHelper.IsAjaxCall && IsPageNoStoreMode ) { LoadControlState(); *************** *** 411,415 **** { string html = sbFull.ToString(); ! CallBackHelper.WriteSetHtmlOfElementScript (html, ClientID); output.Write (html); } --- 411,415 ---- { string html = sbFull.ToString(); ! AjaxCallHelper.WriteSetHtmlOfElementScript (html, ClientID); output.Write (html); } *************** *** 420,424 **** { _controlHtmls.Remove (con); ! CallBackHelper.WriteRemoveElementScript (ClientID, GetAjaxElemID(con)); } --- 420,424 ---- { _controlHtmls.Remove (con); ! AjaxCallHelper.WriteRemoveElementScript (ClientID, GetAjaxElemID(con)); } *************** *** 436,440 **** html = sbFull.ToString(); ! CallBackHelper.WriteAddElementScript (ClientID, "span", GetAjaxElemID(con), html, GetNextExistingElement(i)); output.Write (html); --- 436,440 ---- html = sbFull.ToString(); ! AjaxCallHelper.WriteAddElementScript (ClientID, "span", GetAjaxElemID(con), html, GetNextExistingElement(i)); output.Write (html); *************** *** 484,488 **** private void ExtendedWriteSetHtmlOfElementScript(string html, string elementID) { ! CallBackHelper.Write( String.Format("AJAXCbo.ExtendedSetHtmlOfElementScript({0},\"{1}\");\r\n", CallBackHelper.EncodeString(html), elementID) ); } #endregion --- 484,488 ---- private void ExtendedWriteSetHtmlOfElementScript(string html, string elementID) { ! AjaxCallHelper.Write( String.Format("AJAXCbo.ExtendedSetHtmlOfElementScript({0},\"{1}\");\r\n", AjaxCallHelper.EncodeString(html), elementID) ); } #endregion *************** *** 600,604 **** // so that ':' is used for Unique ID separator instead of '$', // thus javascript to convert the Unique IDs of the page won't be sent ! // at the first CallBack. // Try not using DisableVerify at all if it's IsPageNoStoreMode --- 600,604 ---- // so that ':' is used for Unique ID separator instead of '$', // thus javascript to convert the Unique IDs of the page won't be sent ! // at the first AjaxCall. // Try not using DisableVerify at all if it's IsPageNoStoreMode |
From: Argiris K. <be...@us...> - 2005-11-14 18:50:55
|
Update of /cvsroot/magicajax/magicajax/CustomControls/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30932/CustomControls/script Modified Files: AjaxLinkedPanelListScripts.js Log Message: Replaced all "CallBack" references by "AjaxCall" Index: AjaxLinkedPanelListScripts.js =================================================================== RCS file: /cvsroot/magicajax/magicajax/CustomControls/script/AjaxLinkedPanelListScripts.js,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AjaxLinkedPanelListScripts.js 11 Nov 2005 06:17:49 -0000 1.1 --- AjaxLinkedPanelListScripts.js 14 Nov 2005 18:50:43 -0000 1.2 *************** *** 51,55 **** ShowSelectedPanel(panel); ! AJAXCbo.DoCallBack(linkTarget, "", "async"); } else --- 51,55 ---- ShowSelectedPanel(panel); ! AJAXCbo.DoAjaxCall(linkTarget, "", "async"); } else |
From: Argiris K. <be...@us...> - 2005-11-14 18:50:55
|
Update of /cvsroot/magicajax/magicajax/Core/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30932/Core/script Added Files: AjaxCallObject.js Log Message: Replaced all "CallBack" references by "AjaxCall" --- NEW FILE: AjaxCallObject.js --- __AJAXCboList = new Array(); __bPageIsStored = false; __PreviousOnFormSubmit = null; __PreviousPostBack = null; __PreviousOnPageLoad = null; __PreviousOnPageBeforeUnload = null; __PreviousOnPageUnload = null; function AjaxCallObject() { this.Init(); } AjaxCallObject.prototype.Init = function() { this.XmlHttp = this.GetHttpObject(); } AjaxCallObject.prototype.GetHttpObject = function() { var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/ if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; } AjaxCallObject.prototype.GetAjaxCallType = function(element) { if (element == null) return "none"; var attrib = element.getAttribute("AjaxCall"); if (attrib != null) return attrib.toLowerCase(); if (element.parentNode == null || element.parentNode == document.body) return "none"; else return this.GetAjaxCallType(element.parentNode); } AjaxCallObject.prototype.HookAjaxCall = function(bPageIsStored) { __PreviousOnFormSubmit = document.forms[0].onsubmit; document.forms[0].onsubmit = this.OnFormSubmit; if (typeof __doPostBack != 'undefined') { __PreviousPostBack = __doPostBack; __doPostBack = this.DoPostBack; } if (typeof(RBS_Controls) != "undefined") { for (var i=0; i < RBS_Controls.length; i++) RBS_Controls_Store[i].setAttribute("ExcludeFromPost", "true"); } __PreviousOnPageLoad = window.onload; window.onload = function() { // Restore the html of RenderedByScript controls if (typeof(RBS_Controls) != "undefined") { for (var i=0; i < RBS_Controls.length; i++) { var html = RBS_Controls_Store[i].value; if (html != "") { AJAXCbo.RestoreHtml(RBS_Controls[i], decodeURIComponent(html.substring(5, html.length))); RBS_Controls_Store[i].value = ""; } } } if (__PreviousOnPageLoad != null) return __PreviousOnPageLoad(); }; __PreviousOnPageBeforeUnload = window.onbeforeunload; window.onbeforeunload = function() { // Save the html of RenderedByScript controls, so that it can be restored for the // browser's "Back Button" if (typeof(RBS_Controls) != "undefined") { for (var i=0; i < RBS_Controls.length; i++) RBS_Controls_Store[i].value = "HTML:" + encodeURIComponent(RBS_Controls[i].innerHTML); } if (__PreviousOnPageBeforeUnload != null) return __PreviousOnPageBeforeUnload(); }; if (bPageIsStored) { __PreviousOnPageUnload = window.onunload; window.onunload = this.OnPageUnload; } __bPageIsStored = bPageIsStored; } AjaxCallObject.prototype.OnFormSubmit = function() { var target; if ("activeElement" in document) { // Internet Explorer target = document.activeElement; } else { // Firefox target = arguments[0].explicitOriginalTarget; } if (__PreviousOnFormSubmit != null) if ( __PreviousOnFormSubmit() == false ) return false; var cbType = AJAXCbo.GetAjaxCallType(target); if (cbType != "none") { AJAXCbo.DoAjaxCall(target.name, "", cbType); return false; } else { return true; } } // Replaces normal __doPostBack AjaxCallObject.prototype.DoPostBack = function(eventTarget, eventArgument) { var target; var elemUniqueID = eventTarget.split("$").join(":"); var ids = elemUniqueID.split(":"); // Checks the unique id and its parents until it finds a target element // i.e. for ajaxPanel_grid:row:field it checks // ajaxPanel_grid_row_field // ajaxPanel_grid_row // ajaxPanel_grid for (var num=ids.length; num > 0; num--) { var elemID = ""; for (var i=0; i < num; i++) elemID += (i==0 ? "" : "_") + ids[i]; target = document.getElementById(elemID); if (target != null) break; } var cbType = AJAXCbo.GetAjaxCallType(target); if (cbType != "none") { AJAXCbo.DoAjaxCall(eventTarget, eventArgument, cbType); } else { if (__PreviousPostBack != null) __PreviousPostBack(eventTarget, eventArgument); } } AjaxCallObject.prototype.OnPageUnload = function() { var thePage = document.forms[0].action; var index = thePage.indexOf("?"); if (index != -1) thePage = thePage.substring(0, index); thePage = thePage + "?__AJAX_PAGEUNLOAD=" + encodeURIComponent(document.all["__AJAX_PAGEKEY"].value); var oThis = AJAXCbo; __AJAXCboList.push(oThis); AJAXCbo = new AjaxCallObject(); if( oThis.XmlHttp ) { oThis.XmlHttp.open('GET', thePage, true); oThis.XmlHttp.onreadystatechange = function(){ }; oThis.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); oThis.XmlHttp.send(null); } if (__PreviousOnPageUnload != null) return __PreviousOnPageUnload(); } AjaxCallObject.prototype.DoAjaxCall = function(eventTarget, eventArgument, ajaxCallType) { var theData = ''; var theform = document.forms[0]; var thePage = theform.action; var eName = ''; theData = '__EVENTTARGET=' + escape(eventTarget.split("$").join(":")) + '&'; theData += '__EVENTARGUMENT=' + encodeURIComponent(eventArgument) + '&'; theData += '__AJAXCALL=true&'; if ( ! __bPageIsStored ) theData += '__VIEWSTATE=' + escape(theform.__VIEWSTATE.value).replace(new RegExp('\\+', 'g'), '%2b') + '&'; for( var i=0; i<theform.elements.length; i++ ) { eName = theform.elements[i].name; if( eName && eName != '') { if( eName == '__EVENTTARGET' || eName == '__EVENTARGUMENT' || eName == '__VIEWSTATE' ) { // Do Nothing } else if (theform.elements[i].getAttribute("ExcludeFromPost") == null || theform.elements[i].getAttribute("ExcludeFromPost").toLowerCase() != "true") { var type = theform.elements[i].type; var val = theform.elements[i].value; if ( type == "submit" ) continue; if ( type == "textarea" ) { // Firefox has the bad habit of altering the "\r\n" of a textarea to "\n", // so convert all single "\n" to "\r\n" val = val.split("\r\n").join("\n").split("\n").join("\r\n"); } val = encodeURIComponent(val); if ( type == "select-multiple" ) { for (var j=0; j < theform.elements[i].options.length; j++) if (theform.elements[i].options[j].selected) theData = theData + escape(eName) + '=' + encodeURIComponent(theform.elements[i].options[j].value) + '&'; } else if ( (type != "checkbox" && type != "radio") || theform.elements[i].checked ) { theData = theData + escape(eName) + '=' + val; if( i != theform.elements.length - 1 ) theData = theData + '&'; } } } } if (theData.substring(theData.length-1, theData.length) == "&") theData = theData.substring(0, theData.length-1); if( this.XmlHttp ) { if (waitElement) { waitElement.style.visibility = 'visible'; MoveWaitElement(); } var oThis = this; __AJAXCboList.push(oThis); AJAXCbo = new AjaxCallObject(); if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 ) { if ( ! ajaxCallType || ajaxCallType.toLowerCase() != "sync") { // Asynchronous this.XmlHttp.open("POST", thePage, true); this.XmlHttp.onreadystatechange = function(){ oThis.ReadyStateChange(); }; this.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); this.XmlHttp.send(theData); } else { // Synchronous // Use a timeout so that the screen refreshes before getting stack waiting // the AjaxCall. window.setTimeout( function() { oThis.XmlHttp.open("POST", thePage, false); oThis.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); oThis.XmlHttp.send(theData); if( oThis.XmlHttp.status == 200 && oThis.XmlHttp.statusText == "OK" ) oThis.OnComplete(oThis.XmlHttp.responseText, oThis.XmlHttp.responseXML); else oThis.OnError(oThis.XmlHttp.status, oThis.XmlHttp.statusText, oThis.XmlHttp.responseText); }, 1); } } } } AjaxCallObject.prototype.OnLoading = function() { // Loading } AjaxCallObject.prototype.OnLoaded = function() { // Loaded } AjaxCallObject.prototype.OnInteractive = function() { // Interactive } AjaxCallObject.prototype.OnComplete = function(responseText, responseXml) { //alert(responseText); // Checking if the data were fully loaded, without being aborted var flag = "'AJAX_LOADING_OK';\r\n"; if (responseText.substring(responseText.length - flag.length, responseText.length) != flag) return false; eval(responseText); if (waitElement) waitElement.style.visibility = 'hidden'; return true; } AjaxCallObject.prototype.OnAbort = function() { if (waitElement) waitElement.style.visibility = 'hidden'; } AjaxCallObject.prototype.OnError = function(status, statusText, responseText) { if (waitElement) waitElement.style.visibility = 'hidden'; document.body.innerHTML = responseText; } AjaxCallObject.prototype.ReadyStateChange = function() { if( this.XmlHttp.readyState == 1 ) { this.OnLoading(); } else if( this.XmlHttp.readyState == 2 ) { this.OnLoaded(); } else if( this.XmlHttp.readyState == 3 ) { this.OnInteractive(); } else if( this.XmlHttp.readyState == 4 ) { if( this.XmlHttp.status == 0 ) this.OnAbort(); else if( this.XmlHttp.status == 200 && this.XmlHttp.statusText == "OK" ) this.OnComplete(this.XmlHttp.responseText, this.XmlHttp.responseXML); else this.OnError(this.XmlHttp.status, this.XmlHttp.statusText, this.XmlHttp.responseText); // Remove this AJAXCbo from the list for (var i=0; i < __AJAXCboList.length; i++) if (__AJAXCboList[i] == this) { __AJAXCboList[i].XmlHttp = null; __AJAXCboList.splice(i, 1); break; } } } AjaxCallObject.prototype.ClockID = 0; AjaxCallObject.prototype.SetIntervalForAjaxCall = function(milliSec) { if (this.ClockID) this.ClearIntervalForAjaxCall(); this.ClockID = window.setInterval("AJAXCbo.DoAjaxCall('__AJAX_AJAXCALLTIMER','','async')", milliSec); } AjaxCallObject.prototype.ClearIntervalForAjaxCall = function() { window.clearInterval(this.ClockID); this.ClockID = 0; } AjaxCallObject.prototype.RestoreHtml = function(destElem, html) { var store = document.createElement("form"); store.innerHTML = html; var scripts = store.getElementsByTagName("script"); while (scripts.length > 0) scripts[0].parentNode.removeChild(scripts[0]); var elements = new Array(); var coll = store.getElementsByTagName("INPUT"); for (var i=0; i < coll.length; i++) elements.push(coll[i]); coll = store.getElementsByTagName("TEXTAREA"); for (var i=0; i < coll.length; i++) elements.push(coll[i]); coll = store.getElementsByTagName("SELECT"); for (var i=0; i < coll.length; i++) elements.push(coll[i]); for( var i=0; i < elements.length; i++ ) { var elem = elements[i]; eName = elem.name; if( eName && eName != '') { var type = elem.type; var docElem = document.all[elem.id]; if (docElem == null || docElem.type != type) continue; if ( type == "select-multiple" ) { if ( elem.options.length == docElem.options.length ) { for (var j=0; j < elem.options.length; j++) elem.options[j].selected = docElem.options[j].selected; } } else if ( type == "checkbox" || type == "radio" ) { elem.checked = docElem.checked; } else { elem.value = docElem.value; } } } destElem.innerHTML = store.innerHTML; for( var i=0; i < elements.length; i++ ) { var elem = elements[i]; eName = elem.name; if( eName && eName != '') { var type = elem.type; var docElem = document.all[elem.id]; if (docElem == null || docElem.type != type) continue; if ( type == "select-multiple" ) { if ( elem.options.length == docElem.options.length ) { for (var j=0; j < elem.options.length; j++) docElem.options[j].selected = elem.options[j].selected; } } else if ( type == "checkbox" || type == "radio" ) { docElem.checked = elem.checked; } else { docElem.value = elem.value; } } } } AjaxCallObject.prototype.SetAttributesOfControl = function(clientID, attributes) { var place = document.getElementById(clientID); if (place != null && attributes != "") { var attribs = attributes.split("|"); for (var i=0; i < attribs.length; i++) { var parts = attribs[i].split("="); place.setAttribute(parts[0], parts[1]) } } } AjaxCallObject.prototype.AddElementScript = function(parentID, tagName, elementID, html, beforeElemID) { var place = document.getElementById(parentID); var child = document.getElementById(elementID); if (place != null && child == null) { child = document.createElement(tagName); child.id = elementID; var before = (beforeElemID != null) ? document.getElementById(beforeElemID) : null; place.insertBefore(child, before); } this.SetHtmlOfElementScript (html, elementID); } AjaxCallObject.prototype.RemoveElementScript = function(parentID, elementID) { var place = document.getElementById(parentID); var child = document.getElementById(elementID); if (place != null && child != null) place.removeChild(child); } AjaxCallObject.prototype.SetFieldScript = function(fieldName, fieldValue) { document.all.item(fieldName).value = fieldValue; } AjaxCallObject.prototype.SetHtmlOfElementScript = function(html, elementID) { var place = document.getElementById(elementID); if (place != null) place.innerHTML=html; } AjaxCallObject.prototype.SetHtmlOfPage = function(html) { document.write(html); document.close(); } AjaxCallObject.prototype.SetVisibilityOfElement = function(elementID, visible) { var place = document.getElementById(elementID); if (place != null) place.style.display = (visible) ? "" : "none"; } AjaxCallObject.prototype.Alert = function(message) { window.alert(message); } // It's used by AjaxPanel AjaxCallObject.prototype.ExtendedSetHtmlOfElementScript = function(html, elementID) { var store = document.createElement("span"); store.innerHTML = html; var spans = store.getElementsByTagName("span"); for (var i=0; i < spans.length; i++) { var elem = spans[i]; if (elem.getAttribute("name") == "__ajax_rbs") { var elemOnPage = document.getElementById(elem.id); if (elemOnPage != null) elem.innerHTML = elemOnPage.innerHTML; } } var place=document.getElementById(elementID); if (place != null) place.innerHTML = store.innerHTML; } var AJAXCbo = new AjaxCallObject(); // wait element CreateWaitElement(); window.attachEvent("onscroll", MoveWaitElement); window.attachEvent("onresize", MoveWaitElement); var waitElement; function MoveWaitElement() { if (!waitElement) CreateWaitElement(); var width = document.body.clientWidth; waitElement.style.top = document.body.scrollTop; waitElement.style.left = width + document.body.offsetLeft - waitElement.offsetWidth; } function CreateWaitElement() { var elem = document.getElementById('__AjaxCall_Wait'); if (!elem) { elem = document.createElement("div"); elem.id = '__AjaxCall_Wait'; elem.style.position = 'absolute'; elem.style.height = 17; elem.border = "1px"; elem.style.paddingLeft = "3px"; elem.style.paddingRight = "3px"; elem.style.fontSize = "11px"; elem.style.borderColor = "#ffffff"; elem.style.borderSize = "1px"; elem.style.backgroundColor = "DimGray"; elem.style.color = "#ffffff"; elem.innerHTML = 'Loading ...'; elem.style.visibility = 'hidden'; document.body.insertBefore(elem, document.body.firstChild); } waitElement = elem; } // end wait element |