From: Argiris K. <be...@us...> - 2005-12-12 05:31:29
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13113/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: -The values of form elements are not taken into account for the fingerprint, thus html to update an already updated by the user form element is not sent to client any more. Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** AjaxPanel.cs 9 Dec 2005 17:07:14 -0000 1.35 --- AjaxPanel.cs 12 Dec 2005 05:31:17 -0000 1.36 *************** *** 78,82 **** PersistChildren(true), ToolboxData("<{0}:AjaxPanel runat=server>AjaxPanel</{0}:AjaxPanel>")] ! public class AjaxPanel : RenderedByScriptControl, IFormDataLoadedEventHandler { #region Fields --- 78,82 ---- PersistChildren(true), ToolboxData("<{0}:AjaxPanel runat=server>AjaxPanel</{0}:AjaxPanel>")] ! public class AjaxPanel : RenderedByScriptControl { #region Fields *************** *** 143,195 **** #region Public Methods - #region RaiseFormDataLoadedEvent - /// <summary> - /// Caches the html rendering of the post data changed controls that belong to - /// the AjaxPanel. - /// </summary> - /// <remarks> - /// If a child control is altered by post data, AjaxPanel will send the javascript - /// to refresh the control on the page, but it is unnecessary because the control - /// on the form doesn't need refreshing. - /// This method caches the new html rendering of the controls that received - /// new post data so that the AjaxPanel doesn't think that they were altered. - /// - /// Called by MagicAjaxModule. - /// </remarks> - public virtual void RaiseFormDataLoadedEvent(MagicAjax.Collections.ReadOnlyArrayList changedControls) - { - ArrayList dirtyControls = new ArrayList(); - - for (int i=0; i < changedControls.Count; i++) - { - Control control = (Control) changedControls[i]; - // The top parent of this control that belongs to this AjaxPanel - Control panelChild = FindTopPanelChildOfControl(control); - - if (panelChild != null) - { - dirtyControls.Add (panelChild); - } - } - - if (dirtyControls.Count == 0) - return; - - System.Text.StringBuilder sb = new System.Text.StringBuilder(); - HtmlTextWriter litewriter = new HtmlTextWriter(new System.IO.StringWriter(sb)); - - for (int i=0; i < dirtyControls.Count; i++) - { - Control control = (Control) dirtyControls[i]; - - ExtendedRenderControl (control, litewriter); - - _controlHtmlFingerprints[control] = Util.GetFingerprint(sb.ToString()); - - sb.Length = 0; - } - } - #endregion - #region Clear /// <summary> --- 143,146 ---- *************** *** 433,439 **** { NameValueCollection form = Context.Request.Form; ! RegexOptions options = RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Compiled; ! Regex regEx = new System.Text.RegularExpressions.Regex(@"<(?<tag>input|textarea|select)\s((?<attrname>[-\w]+)=""(?<attrvalue>.*?)""\s?)*.*?(?:/>|>(?<inner>.*?)</(?:textarea|select)>)", options); MatchCollection matches = regEx.Matches(html); for (int i=0; i<matches.Count; i++) --- 384,390 ---- { NameValueCollection form = Context.Request.Form; ! RegexOptions options = RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ExplicitCapture; ! Regex regEx = new System.Text.RegularExpressions.Regex(Util.FormElementPattern, options); MatchCollection matches = regEx.Matches(html); for (int i=0; i<matches.Count; i++) *************** *** 442,447 **** CaptureCollection attrnames = match.Groups["attrname"].Captures; CaptureCollection attrvalues = match.Groups["attrvalue"].Captures; ! ! Hashtable attrNameValues = new Hashtable(); for (int j=0; j< attrnames.Count; j++) { --- 393,398 ---- CaptureCollection attrnames = match.Groups["attrname"].Captures; CaptureCollection attrvalues = match.Groups["attrvalue"].Captures; ! ! Hashtable attrNameValues = new Hashtable(attrnames.Count); for (int j=0; j< attrnames.Count; j++) { *************** *** 478,482 **** case "password": if (value != form[name]) ! AjaxCallHelper.WriteSetFieldScript (name, value); break; case "checkbox": --- 429,433 ---- case "password": if (value != form[name]) ! AjaxCallHelper.WriteSetFieldScript (clientID, value); break; case "checkbox": *************** *** 505,509 **** string text = match.Groups["inner"].Value; if (text != form[name]) ! AjaxCallHelper.WriteSetFieldScript (name, text); break; --- 456,460 ---- string text = match.Groups["inner"].Value; if (text != form[name]) ! AjaxCallHelper.WriteSetFieldScript (clientID, text); break; *************** *** 557,561 **** { if ( oneSelection != form[name] ) ! AjaxCallHelper.WriteSetFieldScript (name, oneSelection); } else --- 508,512 ---- { if ( oneSelection != form[name] ) ! AjaxCallHelper.WriteSetFieldScript (clientID, oneSelection); } else *************** *** 573,577 **** if ( ! elemWritten ) { ! AjaxCallHelper.WriteFormat ("o=document.forms[0][\"{0}\"].options;\r\n", name); elemWritten = true; } --- 524,528 ---- if ( ! elemWritten ) { ! AjaxCallHelper.WriteFormat ("o=document.forms[0][\"{0}\"].options;\r\n", clientID); elemWritten = true; } *************** *** 587,591 **** if ( ! elemWritten ) { ! AjaxCallHelper.WriteFormat ("o=document.forms[0][\"{0}\"];\r\n", name); elemWritten = true; } --- 538,542 ---- if ( ! elemWritten ) { ! AjaxCallHelper.WriteFormat ("o=document.forms[0][\"{0}\"];\r\n", clientID); elemWritten = true; } *************** *** 993,1021 **** #endregion - - #region FindTopPanelChildOfControl - /// <summary> - /// It returns the top parent control of the supplied control, that is an immediate - /// child of this AjaxPanel. If the supplied control is contained inside another - /// AjaxPanel, it returns null. - /// </summary> - /// <remarks> - /// Called by RaiseFormDataLoadedEvent. - /// </remarks> - /// <param name="control"></param> - /// <returns></returns> - private Control FindTopPanelChildOfControl(Control control) - { - if (control.Parent == null) - return null; - else if (control.Parent == this) - return control; - else if (control.Parent is AjaxPanel) - return null; - else - return FindTopPanelChildOfControl(control.Parent); - } - #endregion - #region FindRenderedByScriptControls /// <summary> --- 944,947 ---- |