From: Argiris K. <be...@us...> - 2005-11-20 08:47:44
|
Update of /cvsroot/magicajax/magicajax/Core/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3039/Core/UI Modified Files: AjaxControl.cs AjaxPage.cs AjaxUserControl.cs RenderedByScriptControl.cs Log Message: Fixed the visibility issues and other bugs. Added AjaxCallEnd event for 'Session/Cache' page storing modes. Fixed some comments. Index: AjaxUserControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxUserControl.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AjaxUserControl.cs 18 Nov 2005 18:53:07 -0000 1.5 --- AjaxUserControl.cs 20 Nov 2005 08:47:29 -0000 1.6 *************** *** 27,35 **** { /// <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 --- 27,35 ---- { /// <summary> ! /// Includes the AjaxCall events and some helper properties. /// </summary> /// <remarks> /// Inheriting from AjaxUserControls is not required, you can implement the ! /// IAjaxCallEventHandler on your usercontrol to handle the AjaxCall events. /// </remarks> public class AjaxUserControl : System.Web.UI.UserControl, IAjaxCallEventHandler *************** *** 41,44 **** --- 41,49 ---- /// <summary> + /// Raised by MagicAjaxModule when an AjaxCallEnd occurs + /// </summary> + public event EventHandler AjaxCallEnd; + + /// <summary> /// Raises the AjaxCall event. /// </summary> *************** *** 52,55 **** --- 57,71 ---- /// <summary> + /// Raises the AjaxCallEnd event. + /// </summary> + /// <remarks> + /// Called by MagicAjaxModule. + /// </remarks> + public void RaiseAjaxCallEndEvent() + { + OnAjaxCallEnd (EventArgs.Empty); + } + + /// <summary> /// Determines if the control is being processed during an AjaxCall. /// </summary> *************** *** 65,68 **** --- 81,90 ---- AjaxCall(this, e); } + + protected virtual void OnAjaxCallEnd(EventArgs e) + { + if (AjaxCallEnd != null) + AjaxCallEnd(this, e); + } } } \ No newline at end of file Index: AjaxPage.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxPage.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AjaxPage.cs 18 Nov 2005 18:53:07 -0000 1.5 --- AjaxPage.cs 20 Nov 2005 08:47:29 -0000 1.6 *************** *** 27,35 **** { /// <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 --- 27,35 ---- { /// <summary> ! /// Includes the AjaxCall events and some helper properties. /// </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 events. /// </remarks> public class AjaxPage : System.Web.UI.Page, IAjaxCallEventHandler *************** *** 41,44 **** --- 41,49 ---- /// <summary> + /// Raised by MagicAjaxModule when an AjaxCallEnd occurs + /// </summary> + public event EventHandler AjaxCallEnd; + + /// <summary> /// Raises the AjaxCall event. /// </summary> *************** *** 52,55 **** --- 57,71 ---- /// <summary> + /// Raises the AjaxCallEnd event. + /// </summary> + /// <remarks> + /// Called by MagicAjaxModule. + /// </remarks> + public void RaiseAjaxCallEndEvent() + { + OnAjaxCallEnd (EventArgs.Empty); + } + + /// <summary> /// Determines if the page is being processed during an AjaxCall. /// </summary> *************** *** 65,68 **** --- 81,90 ---- AjaxCall(this, e); } + + protected virtual void OnAjaxCallEnd(EventArgs e) + { + if (AjaxCallEnd != null) + AjaxCallEnd(this, e); + } } } \ No newline at end of file Index: AjaxControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/AjaxControl.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AjaxControl.cs 18 Nov 2005 18:53:07 -0000 1.5 --- AjaxControl.cs 20 Nov 2005 08:47:29 -0000 1.6 *************** *** 39,42 **** --- 39,47 ---- /// <summary> + /// Raised by the MagicAjaxModule. + /// </summary> + public event EventHandler AjaxCallEnd; + + /// <summary> /// Implements the IAjaxCallEventHandler interface. It is called by the MagicAjaxModule. /// </summary> *************** *** 46,49 **** --- 51,62 ---- } + /// <summary> + /// Implements the IAjaxCallEventHandler interface. It is called by the MagicAjaxModule. + /// </summary> + public void RaiseAjaxCallEndEvent() + { + OnAjaxCallEnd(EventArgs.Empty); + } + [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPageNoStoreMode *************** *** 58,62 **** public bool IsAjaxCall { ! get { return AjaxCallHelper.IsAjaxCallForPage(this.Page); } } --- 71,75 ---- public bool IsAjaxCall { ! get { return ( HttpContext.Current != null && this.Page != null && AjaxCallHelper.IsAjaxCallForPage(this.Page) ); } } *************** *** 86,89 **** --- 99,108 ---- AjaxCall(this, e); } + + protected virtual void OnAjaxCallEnd(EventArgs e) + { + if (AjaxCallEnd != null) + AjaxCallEnd(this, e); + } } } Index: RenderedByScriptControl.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/RenderedByScriptControl.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** RenderedByScriptControl.cs 19 Nov 2005 01:31:23 -0000 1.8 --- RenderedByScriptControl.cs 20 Nov 2005 08:47:29 -0000 1.9 *************** *** 21,24 **** --- 21,25 ---- using System; + using System.Web; using System.Web.UI; using System.Web.UI.WebControls; *************** *** 76,79 **** --- 77,81 ---- private string _currentTagHtml = null; private bool _isHtmlRendered = false; + private bool _skipRendering = false; public event RenderStartEventHandler RenderStart; *************** *** 90,94 **** { if ( IsAjaxCall ! && (IsRenderedOnPage || IsPageNoStoreMode) && MonitorVisibilityState && value != base.Visible ) --- 92,96 ---- { if ( IsAjaxCall ! && IsRenderedOnPage && MonitorVisibilityState && value != base.Visible ) *************** *** 109,113 **** /// </remarks> [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] ! public bool IsRenderedOnPage { get { return _isRenderedOnPage; } --- 111,115 ---- /// </remarks> [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] ! public virtual bool IsRenderedOnPage { get { return _isRenderedOnPage; } *************** *** 151,154 **** --- 153,170 ---- /// <summary> + /// Defines wether the Render method will skip rendering completely. + /// </summary> + /// <remarks> + /// Mainly used by AjaxPanel for RenderedByScriptControls that have Visible + /// property set to false. + /// </remarks> + [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + internal bool SkipRendering + { + get { return _skipRendering; } + set { _skipRendering = value; } + } + + /// <summary> /// It defines whether the RenderedByScriptControl was already rendered during /// a normal rendering. *************** *** 160,163 **** --- 176,180 ---- /// In this case it's not necessary to send any javascript to the client. /// </remarks> + [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] protected bool IsHtmlRendered { *************** *** 171,176 **** } ! protected override void OnPreRender(EventArgs e) { if (!IsChildOfRenderedByScriptControl(this)) { --- 188,195 ---- } ! protected override void OnLoad(EventArgs e) { + base.OnLoad (e); + if (!IsChildOfRenderedByScriptControl(this)) { *************** *** 195,202 **** 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); } --- 214,220 ---- Page.RegisterHiddenField(hiddenStore, null); ! Page.RegisterArrayDeclaration("RBS_ControlIDs", String.Format("\"{0}$RBS_Holder\"", this.ClientID)); Page.RegisterArrayDeclaration("RBS_Controls_Store", String.Format("document.all[\"{0}\"]", hiddenStore)); } } *************** *** 222,242 **** protected override void Render(HtmlTextWriter writer) { - if ( IsPageNoStoreMode ) - _isRenderedOnPage = true; - RenderStartEventArgs eventArgs = new RenderStartEventArgs(writer); OnRenderStart(eventArgs); ! if (!eventArgs.AbortRendering) { ! // Put the html of this control inside a SPAN tag so that it can ! // be saved and restored when the page is loaded from the Browser's cache, ! // i.e. when the back button is pressed. ! writer.Write("<span id='{0}$RBS_Holder'>", this.ClientID); ! base.Render (writer); ! writer.Write("</span>"); ! _isHtmlRendered = true; ! _isRenderedOnPage = true; } --- 240,264 ---- protected override void Render(HtmlTextWriter writer) { RenderStartEventArgs eventArgs = new RenderStartEventArgs(writer); OnRenderStart(eventArgs); ! if ( !eventArgs.AbortRendering && !SkipRendering ) { ! if ( !IsAjaxCall || (writer.InnerWriter is IScriptRenderingDisabler && (writer.InnerWriter as IScriptRenderingDisabler).DisableScriptRendering) ) ! { ! // Put the html of this control inside a SPAN tag so that it can ! // be saved and restored when the page is loaded from the Browser's cache, ! // i.e. when the back button is pressed. ! writer.Write("<span id='{0}$RBS_Holder'>", this.ClientID); ! base.Render (writer); ! writer.Write("</span>"); ! _isHtmlRendered = true; ! _isRenderedOnPage = true; ! } ! else ! { ! WriteScript(); ! } } *************** *** 269,278 **** /// If the tag html of the control is changed, send the attributes using javascript. /// </summary> - /// <returns>True if rendering by script was needed, False if it was not</returns> public virtual void WriteScript() { if ( ! this.Visible ) { ! _isRenderedOnPage = HasVisibleNotRenderedByScriptParent(this); return; } --- 291,303 ---- /// If the tag html of the control is changed, send the attributes using javascript. /// </summary> public virtual void WriteScript() { if ( ! this.Visible ) { ! if (_isRenderedOnPage) ! { ! // Verify that it is indeed rendered on page ! _isRenderedOnPage = ( GetTopInvisibleControl(this) is RenderedByScriptControl ); ! } return; } *************** *** 282,304 **** return; - if ( ! IsRenderedOnPage ) - { - Control con = FindNextVisibleSibling(); - AjaxCallHelper.WriteAddElementScript (Parent.ClientID, this.GetTagName(), this.ClientID, "", (con == null) ? null : con.ClientID); - } - System.Text.StringBuilder sb = new System.Text.StringBuilder(); HtmlTextWriter strwriter = new HtmlTextWriter(new System.IO.StringWriter(sb)); ! // Take care of the tag of the control ! base.RenderBeginTag (strwriter); ! string html = sb.ToString(); ! sb.Length = 0; ! if(_currentTagHtml != html) { ! AjaxCallHelper.WriteSetAttributesOfControl (ClientID, FormatAttributes(html)); ! _currentTagHtml = html; } --- 307,342 ---- return; System.Text.StringBuilder sb = new System.Text.StringBuilder(); HtmlTextWriter strwriter = new HtmlTextWriter(new System.IO.StringWriter(sb)); ! if ( ! IsRenderedOnPage ) ! { ! // Put the control's tag on page, inside a RBS_Holder span. ! base.RenderBeginTag (strwriter); ! _currentTagHtml = sb.ToString(); ! base.RenderEndTag (strwriter); ! string html = sb.ToString(); ! Control con = FindNextVisibleSibling(); ! AjaxCallHelper.WriteAddElementScript (Parent.ClientID, "Span", this.ClientID + "$RBS_Holder", html, (con == null) ? null : con.ClientID); ! } ! else { ! // Take care of the tag of the control ! // TODO: Take care of the tag for 'NoStore' mode too. ! ! if ( ! IsPageNoStoreMode ) ! { ! base.RenderBeginTag (strwriter); ! string html = sb.ToString(); ! sb.Length = 0; ! ! if(_currentTagHtml != html) ! { ! AjaxCallHelper.WriteSetAttributesOfControl (ClientID, FormatAttributes(html)); ! _currentTagHtml = html; ! } ! } } *************** *** 308,311 **** --- 346,365 ---- } + /// <summary> + /// Gets the top control that has its Visible property set to false. + /// </summary> + /// <remarks> + /// It's used to determine whether the control is rendered on page or not. + /// </remarks> + /// <param name="control"></param> + /// <returns></returns> + protected Control GetTopInvisibleControl (Control control) + { + if ( control.Parent == null || control.Parent.Visible ) + return control; + else + return GetTopInvisibleControl(control.Parent); + } + protected virtual void OnRenderStart(RenderStartEventArgs eventArgs) { *************** *** 327,350 **** /// <summary> - /// Determines if the given control has a visible parent control that is not - /// of type RenderedByScriptControl. - /// </summary> - /// <remarks> - /// It's used to determine whether the control is rendered on page or not. - /// </remarks> - /// <param name="control"></param> - /// <returns></returns> - private bool HasVisibleNotRenderedByScriptParent(Control control) - { - if (control.Parent == null || control.Parent == control.Page) - return true; - - if (control.Parent is RenderedByScriptControl) - return HasVisibleNotRenderedByScriptParent(control.Parent); - else - return control.Parent.Visible; - } - - /// <summary> /// Finds the next visible control of the control collection of this /// control's parent that has its ID attribute set. --- 381,384 ---- *************** *** 411,414 **** --- 445,460 ---- return attribs.ToString(); } + + /// <summary> + /// Interface used with a HtmlTextWriter to define whether to disable + /// script rendering and do a normal rendering or not. + /// </summary> + protected interface IScriptRenderingDisabler + { + bool DisableScriptRendering + { + get; + } + } } } \ No newline at end of file |