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-12-09 09:45:29
|
Update of /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/App_Data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19561/magicajax/Examples/ExampleSite (.NET 2.0 only)/App_Data Added Files: customers.xml Log Message: Added example site for .NET 2.0 --- NEW FILE: customers.xml --- (This appears to be a binary file; contents omitted.) |
From: Dion O. <dol...@us...> - 2005-12-09 09:43:28
|
Update of /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19148/images Log Message: Directory /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/images added to the repository |
From: Dion O. <dol...@us...> - 2005-12-09 09:43:27
|
Update of /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/webparts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19148/webparts Log Message: Directory /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/webparts added to the repository |
From: Dion O. <dol...@us...> - 2005-12-09 09:43:27
|
Update of /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/examples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19148/examples Log Message: Directory /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/examples added to the repository |
From: Dion O. <dol...@us...> - 2005-12-09 09:43:27
|
Update of /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/App_Data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19148/App_Data Log Message: Directory /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/App_Data added to the repository |
From: Dion O. <dol...@us...> - 2005-12-09 09:43:27
|
Update of /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/Bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19148/Bin Log Message: Directory /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/Bin added to the repository |
From: Dion O. <dol...@us...> - 2005-12-09 09:43:26
|
Update of /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/App_Code In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19148/App_Code Log Message: Directory /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/App_Code added to the repository |
From: Dion O. <dol...@us...> - 2005-12-09 09:42:53
|
Update of /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only) In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19058/ExampleSite (.NET 2.0 only) Log Message: Directory /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only) added to the repository |
From: Argiris K. <be...@us...> - 2005-12-09 01:25:21
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28740/Core/UI/Controls Modified Files: Tag: STABLE AjaxPanel.cs Log Message: Copied changes from HEAD. Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.28 retrieving revision 1.28.2.1 diff -C2 -d -r1.28 -r1.28.2.1 *** AjaxPanel.cs 4 Dec 2005 03:25:15 -0000 1.28 --- AjaxPanel.cs 9 Dec 2005 01:25:06 -0000 1.28.2.1 *************** *** 23,26 **** --- 23,27 ---- using System.ComponentModel; using System.Collections; + using System.Collections.Specialized; using System.Web; using System.Web.UI; *************** *** 29,32 **** --- 30,34 ---- using System.Globalization; using System.Text; + using System.Text.RegularExpressions; namespace MagicAjax.UI.Controls *************** *** 243,251 **** } ! if (IsPageNoStoreMode) ! { ! //disabling clientside validation inside AjaxPanels (not yet handled correctly) ! DisableClientValidators(); ! } } #endregion --- 245,255 ---- } ! //disabling clientside validation inside AjaxPanels (not yet handled correctly) ! // Clientside validation throws errors when a validator becomes invisible ! // during an AjaxCall (the validator is gone while the script checking for ! // it remains). ! // TODO: Find a way to avoid problems of scripts that invisible controls ! // leave behind. ! DisableClientValidators(); } #endregion *************** *** 274,278 **** protected override void AddedControl(Control control, int index) { ! if ( control is WebControl ) { if ( IsPageNoStoreMode ) --- 278,282 ---- protected override void AddedControl(Control control, int index) { ! if ( IsHtmlHolder(control) ) { if ( IsPageNoStoreMode ) *************** *** 299,303 **** protected override void RemovedControl(Control control) { ! if ( control is WebControl ) { if (_addedControls.Contains(control)) --- 303,307 ---- protected override void RemovedControl(Control control) { ! if ( IsHtmlHolder(control) ) { if (_addedControls.Contains(control)) *************** *** 334,341 **** Control con = Controls[i]; ! // Put inside span tag only WebControls ! bool isWebControl = ( con is WebControl ); ! if ( isWebControl ) { writer.WriteBeginTag ("span"); --- 338,345 ---- Control con = Controls[i]; ! // Put inside span tag only html holder controls ! bool isHtmlHolder = IsHtmlHolder(con); ! if ( isHtmlHolder ) { writer.WriteBeginTag ("span"); *************** *** 354,358 **** string html = sb.ToString(); ! if ( isWebControl ) { _controlHtmlFingerprints[con] = Util.GetFingerprint(html); --- 358,362 ---- string html = sb.ToString(); ! if ( isHtmlHolder ) { _controlHtmlFingerprints[con] = Util.GetFingerprint(html); *************** *** 401,405 **** foreach (Control con in this.Controls) { ! if ( con is WebControl ) { if (_controlState.ControlHtmlFingerprints.ContainsKey(con.ClientID)) --- 405,409 ---- foreach (Control con in this.Controls) { ! if ( IsHtmlHolder(con) ) { if (_controlState.ControlHtmlFingerprints.ContainsKey(con.ClientID)) *************** *** 420,423 **** --- 424,870 ---- } + /// <summary> + /// Parses all form input controls from the html, and checks if + /// their values were updated (i.e. different from the current Request.Form values) + /// and sends javascript commands to update the client's form values if necessary. + /// </summary> + /// <param name="html"></param> + protected void ReflectUpdatedFormValues(string html) + { + 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++) + { + Match match = matches[i]; + CaptureCollection attrnames = match.Groups["attrname"].Captures; + CaptureCollection attrvalues = match.Groups["attrvalue"].Captures; + + Hashtable attrNameValues = new Hashtable(); + for (int j=0; j< attrnames.Count; j++) + { + attrNameValues.Add(attrnames[j].Value.ToLower(), attrvalues[j].Value); + } + + // If the form element has the MagicAjax 'ExcludeFromPost' attribute + // set to 'true', ignore it. + if ( attrNameValues.ContainsKey("excludefrompost") + && (attrNameValues["excludefrompost"] as String).ToLower() == "true") + continue; + + string tag = match.Groups["tag"].Value.ToLower(); + string name = (string)attrNameValues["name"]; + string clientID = (string)attrNameValues["id"]; + + if ( name == null ) + continue; + + switch (tag) + { + #region <input> tags + + case "input": + string type = (string)attrNameValues["type"]; + if (type != null) + { + string value = attrNameValues.ContainsKey("value") ? (string)attrNameValues["value"] : String.Empty; + bool isChecked = attrNameValues.ContainsKey("checked"); + + switch (type) + { + case "text": + case "password": + if (value != form[name]) + AjaxCallHelper.WriteSetFieldScript (name, value); + break; + case "checkbox": + if (isChecked != (form[name] != null)) + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked={1};\r\n", name, (isChecked) ? "true" : "false"); + break; + case "radio": + if ( isChecked && form[name] != value ) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=true;\r\n", clientID); + } + else if ( !isChecked && form[name] == value ) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=false;\r\n", clientID); + } + break; + } + } + break; + + #endregion + + #region <textarea> tags + + case "textarea": + string text = match.Groups["inner"].Value; + if (text != form[name]) + AjaxCallHelper.WriteSetFieldScript (name, text); + break; + + #endregion + + #region <select> tags + + case "select": + Regex regExOpt = new System.Text.RegularExpressions.Regex("<option\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*>.*?</option>", options); + bool multiple = attrNameValues.ContainsKey("multiple"); + + ArrayList serverOptions = new ArrayList(); + ArrayList serverSelected = new ArrayList(); + string oneSelection = null; + + //now match the options within this <select> tag + MatchCollection matchesOptions = regExOpt.Matches(match.Groups["inner"].Value); + for (int j = 0; j < matchesOptions.Count; j++) + { + Match matchOption = matchesOptions[j]; + + CaptureCollection attrnamesOption = matchOption.Groups["attrname"].Captures; + CaptureCollection attrvaluesOption = matchOption.Groups["attrvalue"].Captures; + + Hashtable attrNameValuesOption = new Hashtable(); + for (int k = 0; k < attrnamesOption.Count; k++) + { + attrNameValuesOption.Add(attrnamesOption[k].Value.ToLower(), attrvaluesOption[k].Value); + } + + string optValue = (string)attrNameValuesOption["value"]; //TODO: check value encodings etc. + bool optSelected = attrNameValuesOption.ContainsKey("selected"); + + if (optSelected && optValue != null) + { + if ( multiple ) + { + serverSelected.Add (optValue); + } + else + { + oneSelection = optValue; + break; + } + } + + serverOptions.Add (optValue); + } + + if ( ! multiple ) + { + if ( oneSelection != form[name] ) + AjaxCallHelper.WriteSetFieldScript (name, oneSelection); + } + else + { + string[] selections = form.GetValues(name); + if ( selections == null ) + selections = new string[0]; + bool elemWritten = false; + + // Make selections + for (int j=0; j < serverSelected.Count; j++) + { + if (Array.IndexOf(selections, serverSelected[j]) == -1) + { + if ( ! elemWritten ) + { + AjaxCallHelper.WriteFormat ("o=document.forms[0][\"{0}\"].options;\r\n", name); + elemWritten = true; + } + AjaxCallHelper.WriteFormat ("o[{0}].selected=true;\r\n", serverOptions.IndexOf(serverSelected[j])); + } + } + + // Make unselections + for (int j=0; j < selections.Length; j++) + { + if ( ! serverSelected.Contains(selections[j])) + { + if ( ! elemWritten ) + { + AjaxCallHelper.WriteFormat ("o=document.forms[0][\"{0}\"];\r\n", name); + elemWritten = true; + } + AjaxCallHelper.WriteFormat ("o[{0}].selected=false;\r\n", serverOptions.IndexOf(selections[j])); + } + } + } + break; + #endregion + } + + } + } + + /// <summary> + /// Determines whether the AjaxPanel should treat the given control as a separate + /// 'html holder' to compare and 'reflect' its html rendering. + /// </summary> + /// <remarks> + /// Only WebControls, excluding RenderedByScriptControls, are considered html holders. + /// </remarks> + /// <param name="control"></param> + /// <returns></returns> + protected virtual bool IsHtmlHolder (Control control) + { + return ( control is WebControl && !(control is RenderedByScriptControl) ); + } + + protected void ReflectContainedFormControls (Control container) + { + ArrayList elems = new ArrayList(); + if ( container is IPostBackDataHandler ) + elems.Add (container); + elems.AddRange (Util.GetChildControlsOfType(container, typeof(IPostBackDataHandler), typeof(RenderedByScriptControl), true)); + + for (int i=0; i < elems.Count; i++) + ReflectFormControl (elems[i] as Control); + } + + protected void ReflectLiteralFormControls() + { + for (int i=0; i < this.Controls.Count; i++) + { + if ( ! IsHtmlHolder(this.Controls[i]) ) + ReflectContainedFormControls (this.Controls[i]); + } + } + + #region ReflectFormControl + /// <summary> + /// Compares the value of the form control with the value of the client's + /// form element and sends javascript command to corrent the client's element + /// if necessary. + /// </summary> + /// <param name="control"></param> + protected virtual void ReflectFormControl (Control control) + { + NameValueCollection form = Context.Request.Form; + + if ( control is WebControl ) + { + #region Reflecting for WebControls + + string id = control.UniqueID; + + if ( control is RadioButton ) + { + RadioButton radio = control as RadioButton; + int index = radio.UniqueID.LastIndexOf(':'); + string uniqueGroupName = radio.UniqueID.Substring(0, index + 1) + radio.GroupName; + if ( radio.Checked && form[uniqueGroupName] != radio.ID ) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=true;\r\n", control.ClientID); + } + else if ( !radio.Checked && form[uniqueGroupName] == radio.ID ) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=false;\r\n", control.ClientID); + } + } + else if ( control is CheckBox ) + { + if ( !(control.Parent is CheckBoxList) ) + { + CheckBox chkbox = control as CheckBox; + if ( chkbox.Checked != (form[id] != null) ) + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked={1};\r\n", id, (chkbox.Checked) ? "true" : "false"); + } + } + else if ( control is CheckBoxList ) + { + CheckBoxList chklist = control as CheckBoxList; + for (int i=0; i < chklist.Items.Count; i++) + { + string itemid = String.Format("{0}:{1}", id, i); + if ( chklist.Items[i].Selected != (form[itemid] != null) ) + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked={1};\r\n", itemid, (chklist.Items[i].Selected) ? "true" : "false"); + } + } + else if ( control is DropDownList ) + { + DropDownList ddlist = control as DropDownList; + if ( (ddlist.SelectedIndex == -1 && form[id] != null) + || ddlist.SelectedValue != form[id] ) + AjaxCallHelper.WriteSetFieldScript (id, ddlist.SelectedValue); + } + else if ( control is ListBox ) + { + ListBox lstbox = control as ListBox; + if ( ListSelectionMode.Single == lstbox.SelectionMode ) + { + if ( (lstbox.SelectedIndex == -1 && form[id] != null) + || lstbox.SelectedValue != form[id] ) + AjaxCallHelper.WriteSetFieldScript (id, lstbox.SelectedValue); + } + else + { + string[] selections = form.GetValues(id); + bool elemWritten = false; + + // Make selections + for (int i=0; i < lstbox.Items.Count; i++) + { + if (lstbox.Items[i].Selected && Array.IndexOf(selections, lstbox.Items[i].Value) == -1) + { + if ( ! elemWritten ) + { + AjaxCallHelper.WriteFormat ("elem=document.forms[0][\"{0}\"];\r\n", id); + elemWritten = true; + } + AjaxCallHelper.WriteFormat ("elem.options[{0}].selected=true;\r\n", i); + } + } + + // Make unselections + for (int i=0; i < selections.Length; i++) + { + for (int itemi=0; itemi < lstbox.Items.Count; itemi++) + { + if ( lstbox.Items[itemi].Value == selections[i] ) + { + if ( ! lstbox.Items[itemi].Selected ) + { + if ( ! elemWritten ) + { + AjaxCallHelper.WriteFormat ("elem=document.forms[0][\"{0}\"];\r\n", id); + elemWritten = true; + } + AjaxCallHelper.WriteFormat ("elem.options[{0}].selected=false;\r\n", itemi); + } + break; + } + } + } + } + } + else if ( control is RadioButtonList ) + { + RadioButtonList rblist = control as RadioButtonList; + if ( rblist.SelectedIndex == -1 && form[id] != null ) + { + // Clear selection + for (int i=0; i < rblist.Items.Count; i++) + { + if (rblist.Items[i].Value == form[id]) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=false;\r\n", String.Format("{0}_{1}", control.ClientID, i)); + break; + } + } + } + else if ( rblist.SelectedIndex != -1 && rblist.SelectedValue != form[id] ) + { + // Make selection + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=true;\r\n", String.Format("{0}_{1}", control.ClientID, rblist.SelectedIndex)); + } + } + else if ( control is TextBox ) + { + TextBox txtbox = control as TextBox; + if ( txtbox.Text != form[id] ) + AjaxCallHelper.WriteSetFieldScript (id, txtbox.Text); + } + + #endregion + } + else if ( control is HtmlControl ) + { + #region Reflecting for HtmlControls + + if ( control is HtmlInputCheckBox ) + { + HtmlInputCheckBox chkbox = control as HtmlInputCheckBox; + if ( chkbox.Checked != (form[chkbox.Name] != null) ) + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked={1};\r\n", chkbox.Name, (chkbox.Checked) ? "true" : "false"); + } + else if ( control is HtmlInputRadioButton ) + { + HtmlInputRadioButton radio = control as HtmlInputRadioButton; + if ( radio.Name != String.Empty ) + { + int index = radio.UniqueID.LastIndexOf(':'); + string uniqueName = radio.UniqueID.Substring(0, index + 1) + radio.Name; + if ( radio.Checked && form[uniqueName] != radio.ID ) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=true;\r\n", control.ClientID); + } + else if ( !radio.Checked && form[uniqueName] == radio.ID ) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=false;\r\n", control.ClientID); + } + } + } + else if ( control is HtmlInputText ) + { + HtmlInputText txtbox = control as HtmlInputText; + if ( txtbox.Value != form[txtbox.Name] ) + AjaxCallHelper.WriteSetFieldScript (txtbox.Name, txtbox.Value); + } + else if ( control is HtmlSelect ) + { + HtmlSelect sel = control as HtmlSelect; + if ( ! sel.Multiple ) + { + if ( (sel.SelectedIndex == -1 && form[sel.Name] != null) + || sel.Value != form[sel.Name] ) + AjaxCallHelper.WriteSetFieldScript (sel.Name, sel.Value); + } + else + { + string[] selections = form.GetValues(sel.Name); + bool elemWritten = false; + + // Make selections + for (int i=0; i < sel.Items.Count; i++) + { + if (sel.Items[i].Selected && Array.IndexOf(selections, sel.Items[i].Value) == -1) + { + if ( ! elemWritten ) + { + AjaxCallHelper.WriteFormat ("elem=document.forms[0][\"{0}\"];\r\n", sel.Name); + elemWritten = true; + } + AjaxCallHelper.WriteFormat ("elem.options[{0}].selected=true;\r\n", i); + } + } + + // Make unselections + for (int i=0; i < selections.Length; i++) + { + for (int itemi=0; itemi < sel.Items.Count; itemi++) + { + if ( sel.Items[itemi].Value == selections[i] ) + { + if ( ! sel.Items[itemi].Selected ) + { + if ( ! elemWritten ) + { + AjaxCallHelper.WriteFormat ("elem=document.forms[0][\"{0}\"];\r\n", sel.Name); + elemWritten = true; + } + AjaxCallHelper.WriteFormat ("elem.options[{0}].selected=false;\r\n", itemi); + } + break; + } + } + } + } + } + else if ( control is HtmlTextArea ) + { + HtmlTextArea txtbox = control as HtmlTextArea; + if ( txtbox.Value != form[txtbox.Name] ) + AjaxCallHelper.WriteSetFieldScript (txtbox.Name, txtbox.Value); + } + + #endregion + } + } + #endregion + #region override PutTagOnPageForAjaxCall /// <summary> *************** *** 479,486 **** Control con = Controls[i]; ! // Put inside span tag only WebControls ! bool isWebControl = ( con is WebControl ); ! if ( isWebControl ) { fullwriter.WriteBeginTag ("span"); --- 926,933 ---- Control con = Controls[i]; ! // Put inside span tag only html holder controls ! bool isHtmlHolder = IsHtmlHolder(con); ! if ( isHtmlHolder ) { fullwriter.WriteBeginTag ("span"); *************** *** 498,502 **** string html = sb.ToString(); ! if ( isWebControl ) { fullwriter.WriteEndTag ("span"); --- 945,949 ---- string html = sb.ToString(); ! if ( isHtmlHolder ) { fullwriter.WriteEndTag ("span"); *************** *** 524,528 **** // Increase script writing level because we want literal content to // be rendered before the child controls renderings ! AjaxCallHelper.IncreaseWritingLevel(); foreach (Control con in _removedControls) --- 971,975 ---- // Increase script writing level because we want literal content to // be rendered before the child controls renderings ! AjaxCallHelper.IncreaseWritingLevel(); foreach (Control con in _removedControls) *************** *** 535,542 **** Control con = Controls[i]; ! // Only WebControls are inside a span tag ! bool isWebControl = ( con is WebControl ); ! if ( isWebControl ) { literalwriter.WriteBeginTag ("span"); --- 982,989 ---- Control con = Controls[i]; ! // Only html holder controls are inside a span tag ! bool isHtmlHolder = IsHtmlHolder(con); ! if ( isHtmlHolder ) { literalwriter.WriteBeginTag ("span"); *************** *** 550,554 **** sbFull.Length = sb.Length = 0; ! if ( isWebControl && _addedControls.Contains(con) ) { // It's a new control, create it on the client at the appropriate place. --- 997,1001 ---- sbFull.Length = sb.Length = 0; ! if ( isHtmlHolder && _addedControls.Contains(con) ) { // It's a new control, create it on the client at the appropriate place. *************** *** 575,585 **** html = sb.ToString(); ! if ( isWebControl ) { string htmlFingerprint = Util.GetFingerprint(html); ! ! // If it's html rendering fingerprint is the same, ignore it. ! if (htmlFingerprint != (string)_controlHtmlFingerprints[con]) { ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); _controlHtmlFingerprints[con] = htmlFingerprint; --- 1022,1039 ---- html = sb.ToString(); ! if ( isHtmlHolder ) { string htmlFingerprint = Util.GetFingerprint(html); ! if (htmlFingerprint == (string)_controlHtmlFingerprints[con]) ! { ! // Its html rendering fingerprint is the same, ignore the ! // html and "reflect" the form elements that it contains ! // on client's page if they're different. ! ReflectUpdatedFormValues (html); ! } ! else { + // Its html rendering fingerprint has changed, + // "reflect" its html on client. ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); _controlHtmlFingerprints[con] = htmlFingerprint; *************** *** 602,606 **** string literalhtml = sbLiteral.ToString(); string literalFingerprint = Util.GetFingerprint(literalhtml); ! if ( _controlState.LiteralFingerprint != literalFingerprint ) { ExtendedWriteSetHtmlOfElementScript (literalhtml, this.ClientID); --- 1056,1067 ---- string literalhtml = sbLiteral.ToString(); string literalFingerprint = Util.GetFingerprint(literalhtml); ! if ( literalFingerprint == _controlState.LiteralFingerprint ) ! { ! // Its html rendering fingerprint is the same, ignore the ! // html and "reflect" the form elements that it contains ! // on client's page if they're different. ! ReflectUpdatedFormValues (literalhtml); ! } ! else { ExtendedWriteSetHtmlOfElementScript (literalhtml, this.ClientID); *************** *** 765,769 **** private void InitValidators() { ! ArrayList validators = Util.GetChildControlsOfType(this, typeof(BaseValidator), true); foreach (BaseValidator validator in validators) { --- 1226,1230 ---- private void InitValidators() { ! ArrayList validators = Util.GetChildControlsOfType(this, typeof(BaseValidator), typeof(RenderedByScriptControl), true); foreach (BaseValidator validator in validators) { *************** *** 776,780 **** private void DisableClientValidators() { ! ArrayList validators = Util.GetChildControlsOfType(this, typeof(BaseValidator), true); foreach (BaseValidator validator in validators) { --- 1237,1241 ---- private void DisableClientValidators() { ! ArrayList validators = Util.GetChildControlsOfType(this, typeof(BaseValidator), typeof(RenderedByScriptControl), true); foreach (BaseValidator validator in validators) { |
From: Argiris K. <be...@us...> - 2005-12-09 01:25:21
|
Update of /cvsroot/magicajax/magicajax/Docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28740/Docs Modified Files: Tag: STABLE Changelog.html Limitations.html Log Message: Copied changes from HEAD. Index: Limitations.html =================================================================== RCS file: /cvsroot/magicajax/magicajax/Docs/Limitations.html,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -C2 -d -r1.1 -r1.1.4.1 *** Limitations.html 27 Nov 2005 17:30:01 -0000 1.1 --- Limitations.html 9 Dec 2005 01:25:07 -0000 1.1.4.1 *************** *** 56,60 **** <p class="MainHeader" align="left">MagicAjax Limitations</p> <p class="MainContent"> ! These are the currently known limitations of MagicAjax v0.2.:</p> <p class="MainContent"> <UL> --- 56,60 ---- <p class="MainHeader" align="left">MagicAjax Limitations</p> <p class="MainContent"> ! These are the currently known limitations of MagicAjax :</p> <p class="MainContent"> <UL> *************** *** 62,65 **** --- 62,68 ---- Only IE and Firefox browsers are supported. MagicAjax will be disabled for other browsers and the page will work with plain PostBacks + <LI> + Clientside validation is not handled properly; It is disabled + for validators inside an AjaxPanel <li> For the <a href="Configuration.html#mode">NoStore PageStore mode</a>, if the Index: Changelog.html =================================================================== RCS file: /cvsroot/magicajax/magicajax/Docs/Changelog.html,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -C2 -d -r1.4.2.1 -r1.4.2.2 *** Changelog.html 5 Dec 2005 18:42:05 -0000 1.4.2.1 --- Changelog.html 9 Dec 2005 01:25:07 -0000 1.4.2.2 *************** *** 57,62 **** <p>Changes since 0.2.1</p> <ul> <LI> ! Added 'WriteFormat' and 'WriteLine' methods at AjaxCallHelper.cs</LI> <LI> Added check of browser type "NetScape5" for MagicAjaxContext's --- 57,65 ---- <p>Changes since 0.2.1</p> <ul> + <li> + Now AjaxPanel takes into account the changes made to form elements by the user + and updates their values when necessary <LI> ! Added 'WriteFormat' and 'WriteLine' methods at AjaxCallHelper.cs <LI> Added check of browser type "NetScape5" for MagicAjaxContext's *************** *** 72,77 **** of an AjaxCall <LI> ! All clientside validators inside AjaxPanels are disabled (for NoStore mode ! only); This solves clientside validation script errors. <li> Fix for the clientside WaitElement. Now works for IE5.5, IE6 and FireFox. --- 75,80 ---- of an AjaxCall <LI> ! All clientside validators inside AjaxPanels are disabled; This solves ! clientside validation script errors. <li> Fix for the clientside WaitElement. Now works for IE5.5, IE6 and FireFox. |
From: Argiris K. <be...@us...> - 2005-12-09 01:25:21
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28740/Core Modified Files: Tag: STABLE MagicAjaxModule.cs Util.cs Log Message: Copied changes from HEAD. Index: Util.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Util.cs,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -C2 -d -r1.13 -r1.13.2.1 *** Util.cs 4 Dec 2005 03:25:15 -0000 1.13 --- Util.cs 9 Dec 2005 01:25:06 -0000 1.13.2.1 *************** *** 138,142 **** } ! public static ArrayList GetChildControlsOfType (Control parentControl, Type type, bool onlyVisible) { ArrayList list = new ArrayList(); --- 138,150 ---- } ! /// <summary> ! /// Gets all child controls of a specific type. ! /// </summary> ! /// <param name="parentControl">Control to search</param> ! /// <param name="searchType">The type to search for</param> ! /// <param name="notRecursiveType">If not null, the child controls of this type are not searched</param> ! /// <param name="onlyVisible">if true gets only the visible controls</param> ! /// <returns></returns> ! public static ArrayList GetChildControlsOfType (Control parentControl, Type searchType, Type notRecursiveType, bool onlyVisible) { ArrayList list = new ArrayList(); *************** *** 148,155 **** continue; ! if ( type.IsInstanceOfType(con) ) list.Add (con); ! list.AddRange (GetChildControlsOfType(con, type, onlyVisible)); } --- 156,164 ---- continue; ! if ( searchType.IsInstanceOfType(con) ) list.Add (con); ! if ( notRecursiveType == null || !notRecursiveType.IsInstanceOfType(con) ) ! list.AddRange (GetChildControlsOfType(con, searchType, notRecursiveType, onlyVisible)); } Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.38 retrieving revision 1.38.2.1 diff -C2 -d -r1.38 -r1.38.2.1 *** MagicAjaxModule.cs 2 Dec 2005 08:25:10 -0000 1.38 --- MagicAjaxModule.cs 9 Dec 2005 01:25:06 -0000 1.38.2.1 *************** *** 576,580 **** { // Restore the validators ! ArrayList validators = Util.GetChildControlsOfType(_magicAjaxContext.StoredPageInfo.Page, typeof(IValidator), false); foreach (IValidator valid in validators) _magicAjaxContext.StoredPageInfo.Page.Validators.Add(valid); --- 576,580 ---- { // Restore the validators ! ArrayList validators = Util.GetChildControlsOfType(_magicAjaxContext.StoredPageInfo.Page, typeof(IValidator), null, false); foreach (IValidator valid in validators) _magicAjaxContext.StoredPageInfo.Page.Validators.Add(valid); |
From: Argiris K. <be...@us...> - 2005-12-09 01:24:13
|
Update of /cvsroot/magicajax/magicajax/Docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28382/Docs Modified Files: Changelog.html Limitations.html Log Message: Fixed a bug of 'ReflectUpdatedFormValues' when handling <input> tags. Disabled clientside validation for storing page modes as well. Updated 'ChangeLog' and 'Limitation' docs. Index: Limitations.html =================================================================== RCS file: /cvsroot/magicajax/magicajax/Docs/Limitations.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Limitations.html 27 Nov 2005 17:30:01 -0000 1.1 --- Limitations.html 9 Dec 2005 01:24:00 -0000 1.2 *************** *** 56,60 **** <p class="MainHeader" align="left">MagicAjax Limitations</p> <p class="MainContent"> ! These are the currently known limitations of MagicAjax v0.2.:</p> <p class="MainContent"> <UL> --- 56,60 ---- <p class="MainHeader" align="left">MagicAjax Limitations</p> <p class="MainContent"> ! These are the currently known limitations of MagicAjax :</p> <p class="MainContent"> <UL> *************** *** 62,65 **** --- 62,68 ---- Only IE and Firefox browsers are supported. MagicAjax will be disabled for other browsers and the page will work with plain PostBacks + <LI> + Clientside validation is not handled properly; It is disabled + for validators inside an AjaxPanel <li> For the <a href="Configuration.html#mode">NoStore PageStore mode</a>, if the Index: Changelog.html =================================================================== RCS file: /cvsroot/magicajax/magicajax/Docs/Changelog.html,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Changelog.html 5 Dec 2005 18:40:50 -0000 1.5 --- Changelog.html 9 Dec 2005 01:24:00 -0000 1.6 *************** *** 58,61 **** --- 58,64 ---- <ul> <li> + Now AjaxPanel takes into account the changes made to form elements by the user + and updates their values when necessary + <LI> Added 'WriteFormat' and 'WriteLine' methods at AjaxCallHelper.cs <LI> *************** *** 72,77 **** of an AjaxCall <LI> ! All clientside validators inside AjaxPanels are disabled (for NoStore mode ! only); This solves clientside validation script errors. <li> Fix for the clientside WaitElement. Now works for IE5.5, IE6 and FireFox. --- 75,80 ---- of an AjaxCall <LI> ! All clientside validators inside AjaxPanels are disabled; This solves ! clientside validation script errors. <li> Fix for the clientside WaitElement. Now works for IE5.5, IE6 and FireFox. |
From: Argiris K. <be...@us...> - 2005-12-09 01:24:13
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28382/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Fixed a bug of 'ReflectUpdatedFormValues' when handling <input> tags. Disabled clientside validation for storing page modes as well. Updated 'ChangeLog' and 'Limitation' docs. Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** AjaxPanel.cs 8 Dec 2005 18:15:02 -0000 1.32 --- AjaxPanel.cs 9 Dec 2005 01:23:59 -0000 1.33 *************** *** 245,253 **** } ! if (IsPageNoStoreMode) ! { ! //disabling clientside validation inside AjaxPanels (not yet handled correctly) ! DisableClientValidators(); ! } } #endregion --- 245,255 ---- } ! //disabling clientside validation inside AjaxPanels (not yet handled correctly) ! // Clientside validation throws errors when a validator becomes invisible ! // during an AjaxCall (the validator is gone while the script checking for ! // it remains). ! // TODO: Find a way to avoid problems of scripts that invisible controls ! // leave behind. ! DisableClientValidators(); } #endregion *************** *** 425,570 **** /// Parses all form input controls from the html, and checks if /// their values were updated (i.e. different from the current Request.Form values) - /// </summary> - /// <param name="html"></param> - protected bool ContainsUpdatedFormValues(string html) - { - NameValueCollection form = Context.Request.Form; - RegexOptions options = RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Compiled; - - #region Check <input> tags - // - // Check <input> tags - // - Regex regEx = new System.Text.RegularExpressions.Regex("<input\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*/>", options); - MatchCollection matches = regEx.Matches(html); - for (int i=0; i<matches.Count; i++) - { - Match match = matches[i]; - CaptureCollection attrnames = match.Groups["attrname"].Captures; - CaptureCollection attrvalues = match.Groups["attrvalue"].Captures; - - Hashtable attrNameValues = new Hashtable(); - for (int j=0; j< attrnames.Count; j++) - { - attrNameValues.Add(attrnames[j].Value.ToLower(), attrvalues[j].Value); - } - - string type = (string)attrNameValues["type"]; - string name = (string)attrNameValues["name"]; - string value = attrNameValues.ContainsKey("value") ? (string)attrNameValues["value"] : string.Empty; - bool isChecked = attrNameValues.ContainsKey("checked"); - - if (type != null && name != null) - { - switch (type) - { - case "text": - case "password": - if (value != form[name]) - return true; - break; - case "checkbox": - if (isChecked != (form[name] != null)) - return true; - break; - case "radio": - if ((isChecked && form[name] != value) || (!isChecked && form[name] == value)) - return true; - break; - } - } - } - #endregion - - #region Check <textarea> tags - // - // Check <textarea> tags - // - regEx = new System.Text.RegularExpressions.Regex("<textarea\\s.*?name=\"(?<name>[-\\w]+)\".*?>(?<value>.*?)</textarea>", options); - matches = regEx.Matches(html); - for (int i=0; i<matches.Count; i++) - { - Match match = matches[i]; - string name = match.Groups["name"].Value; - string value = match.Groups["value"].Success ? match.Groups["value"].Value : string.Empty; - - if (value != form[name]) - return true; - } - #endregion - - #region Check <select> tags - // - // Check <select> tags - // - Regex regExSelect = new System.Text.RegularExpressions.Regex("<select\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*>(?<options>.*?)</select>", options); - Regex regExOption = new System.Text.RegularExpressions.Regex("<option\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*>.*?</option>", options); - matches = regExSelect.Matches(html); - for (int i=0; i<matches.Count; i++) - { - Match matchSelect = matches[i]; - CaptureCollection attrnamesSelect = matchSelect.Groups["attrname"].Captures; - CaptureCollection attrvaluesSelect = matchSelect.Groups["attrvalue"].Captures; - - Hashtable attrNameValuesSelect = new Hashtable(); - for (int j = 0; j < attrnamesSelect.Count; j++) - { - attrNameValuesSelect.Add(attrnamesSelect[j].Value.ToLower(), attrvaluesSelect[j].Value); - } - - string name = (string)attrNameValuesSelect["name"]; - bool multiple = attrNameValuesSelect.ContainsKey("multiple"); - bool isDropDown = !attrNameValuesSelect.ContainsKey("size"); - - if (name != null) - { - string serverValue = null; - - //now match the <option>s within this <select> tag - MatchCollection matchesOption = regExOption.Matches(matchSelect.Groups["options"].Value); - for (int j = 0; j < matchesOption.Count; j++) - { - Match matchOption = matchesOption[j]; - CaptureCollection attrnamesOption = matchOption.Groups["attrname"].Captures; - CaptureCollection attrvaluesOption = matchOption.Groups["attrvalue"].Captures; - - Hashtable attrNameValuesOption = new Hashtable(); - for (int k = 0; k < attrnamesOption.Count; k++) - { - attrNameValuesOption.Add(attrnamesOption[k].Value.ToLower(), attrvaluesOption[k].Value); - } - - string optValue = (string)attrNameValuesOption["value"]; //TODO: check value encodings etc. - bool optSelected = attrNameValuesOption.ContainsKey("selected"); - - if (!multiple) - { - //for dropdowns: start with picking first item - if (isDropDown && serverValue == null) - serverValue = optValue; - if (optSelected) - { - serverValue = optValue; - break; - } - } - else if (optSelected) - { - serverValue += (serverValue == null ? string.Empty : ",") + optValue; - } - } - - if (serverValue != form[name]) - return true; - } - } - #endregion - - return false; - } - - /// <summary> - /// Parses all form input controls from the html, and checks if - /// their values were updated (i.e. different from the current Request.Form values) /// and sends javascript commands to update the client's form values if necessary. /// </summary> --- 427,430 ---- *************** *** 589,592 **** --- 449,458 ---- } + // If the form element has the MagicAjax 'ExcludeFromPost' attribute + // set to 'true', ignore it. + if ( attrNameValues.ContainsKey("excludefrompost") + && (attrNameValues["excludefrompost"] as String).ToLower() == "true") + continue; + string tag = match.Groups["tag"].Value.ToLower(); string name = (string)attrNameValues["name"]; *************** *** 604,608 **** if (type != null) { ! string value = (string)attrNameValues["value"]; bool isChecked = attrNameValues.ContainsKey("checked"); --- 470,474 ---- if (type != null) { ! string value = attrNameValues.ContainsKey("value") ? (string)attrNameValues["value"] : String.Empty; bool isChecked = attrNameValues.ContainsKey("checked"); *************** *** 696,699 **** --- 562,567 ---- { string[] selections = form.GetValues(name); + if ( selections == null ) + selections = new string[0]; bool elemWritten = false; *************** *** 1157,1172 **** { string htmlFingerprint = Util.GetFingerprint(html); - - //previous code, commented by Argiris - // - //if (htmlFingerprint != (string)_controlHtmlFingerprints[con] - // || ContainsUpdatedFormValues(html)) - //{ - // // Its html rendering fingerprint has changed, - // // "reflect" its html on client. - // ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); - // _controlHtmlFingerprints[con] = htmlFingerprint; - //} - if (htmlFingerprint == (string)_controlHtmlFingerprints[con]) { --- 1025,1028 ---- |
From: Argiris K. <be...@us...> - 2005-12-08 18:15:24
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19223/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Added "ReflectUpdatedFormValues" method that issues javascript commands for changed form elements. Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** AjaxPanel.cs 8 Dec 2005 11:33:50 -0000 1.31 --- AjaxPanel.cs 8 Dec 2005 18:15:02 -0000 1.32 *************** *** 565,568 **** --- 565,737 ---- /// <summary> + /// Parses all form input controls from the html, and checks if + /// their values were updated (i.e. different from the current Request.Form values) + /// and sends javascript commands to update the client's form values if necessary. + /// </summary> + /// <param name="html"></param> + protected void ReflectUpdatedFormValues(string html) + { + 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++) + { + Match match = matches[i]; + CaptureCollection attrnames = match.Groups["attrname"].Captures; + CaptureCollection attrvalues = match.Groups["attrvalue"].Captures; + + Hashtable attrNameValues = new Hashtable(); + for (int j=0; j< attrnames.Count; j++) + { + attrNameValues.Add(attrnames[j].Value.ToLower(), attrvalues[j].Value); + } + + string tag = match.Groups["tag"].Value.ToLower(); + string name = (string)attrNameValues["name"]; + string clientID = (string)attrNameValues["id"]; + + if ( name == null ) + continue; + + switch (tag) + { + #region <input> tags + + case "input": + string type = (string)attrNameValues["type"]; + if (type != null) + { + string value = (string)attrNameValues["value"]; + bool isChecked = attrNameValues.ContainsKey("checked"); + + switch (type) + { + case "text": + case "password": + if (value != form[name]) + AjaxCallHelper.WriteSetFieldScript (name, value); + break; + case "checkbox": + if (isChecked != (form[name] != null)) + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked={1};\r\n", name, (isChecked) ? "true" : "false"); + break; + case "radio": + if ( isChecked && form[name] != value ) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=true;\r\n", clientID); + } + else if ( !isChecked && form[name] == value ) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=false;\r\n", clientID); + } + break; + } + } + break; + + #endregion + + #region <textarea> tags + + case "textarea": + string text = match.Groups["inner"].Value; + if (text != form[name]) + AjaxCallHelper.WriteSetFieldScript (name, text); + break; + + #endregion + + #region <select> tags + + case "select": + Regex regExOpt = new System.Text.RegularExpressions.Regex("<option\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*>.*?</option>", options); + bool multiple = attrNameValues.ContainsKey("multiple"); + + ArrayList serverOptions = new ArrayList(); + ArrayList serverSelected = new ArrayList(); + string oneSelection = null; + + //now match the options within this <select> tag + MatchCollection matchesOptions = regExOpt.Matches(match.Groups["inner"].Value); + for (int j = 0; j < matchesOptions.Count; j++) + { + Match matchOption = matchesOptions[j]; + + CaptureCollection attrnamesOption = matchOption.Groups["attrname"].Captures; + CaptureCollection attrvaluesOption = matchOption.Groups["attrvalue"].Captures; + + Hashtable attrNameValuesOption = new Hashtable(); + for (int k = 0; k < attrnamesOption.Count; k++) + { + attrNameValuesOption.Add(attrnamesOption[k].Value.ToLower(), attrvaluesOption[k].Value); + } + + string optValue = (string)attrNameValuesOption["value"]; //TODO: check value encodings etc. + bool optSelected = attrNameValuesOption.ContainsKey("selected"); + + if (optSelected && optValue != null) + { + if ( multiple ) + { + serverSelected.Add (optValue); + } + else + { + oneSelection = optValue; + break; + } + } + + serverOptions.Add (optValue); + } + + if ( ! multiple ) + { + if ( oneSelection != form[name] ) + AjaxCallHelper.WriteSetFieldScript (name, oneSelection); + } + else + { + string[] selections = form.GetValues(name); + bool elemWritten = false; + + // Make selections + for (int j=0; j < serverSelected.Count; j++) + { + if (Array.IndexOf(selections, serverSelected[j]) == -1) + { + if ( ! elemWritten ) + { + AjaxCallHelper.WriteFormat ("o=document.forms[0][\"{0}\"].options;\r\n", name); + elemWritten = true; + } + AjaxCallHelper.WriteFormat ("o[{0}].selected=true;\r\n", serverOptions.IndexOf(serverSelected[j])); + } + } + + // Make unselections + for (int j=0; j < selections.Length; j++) + { + if ( ! serverSelected.Contains(selections[j])) + { + if ( ! elemWritten ) + { + AjaxCallHelper.WriteFormat ("o=document.forms[0][\"{0}\"];\r\n", name); + elemWritten = true; + } + AjaxCallHelper.WriteFormat ("o[{0}].selected=false;\r\n", serverOptions.IndexOf(selections[j])); + } + } + } + break; + #endregion + } + + } + } + + /// <summary> /// Determines whether the AjaxPanel should treat the given control as a separate /// 'html holder' to compare and 'reflect' its html rendering. *************** *** 575,589 **** protected virtual bool IsHtmlHolder (Control control) { ! return ( control is WebControl && !(control is RenderedByScriptControl) ); } protected void ReflectContainedFormControls (Control container) { ! ArrayList elems = new ArrayList(); if ( container is IPostBackDataHandler ) elems.Add (container); elems.AddRange (Util.GetChildControlsOfType(container, typeof(IPostBackDataHandler), typeof(RenderedByScriptControl), true)); ! for (int i=0; i < elems.Count; i++) ReflectFormControl (elems[i] as Control); } --- 744,758 ---- protected virtual bool IsHtmlHolder (Control control) { ! return ( control is WebControl && !(control is RenderedByScriptControl) ); } protected void ReflectContainedFormControls (Control container) { ! ArrayList elems = new ArrayList(); if ( container is IPostBackDataHandler ) elems.Add (container); elems.AddRange (Util.GetChildControlsOfType(container, typeof(IPostBackDataHandler), typeof(RenderedByScriptControl), true)); ! for (int i=0; i < elems.Count; i++) ReflectFormControl (elems[i] as Control); } *************** *** 618,622 **** { RadioButton radio = control as RadioButton; ! int index = radio.UniqueID.LastIndexOf(':'); string uniqueGroupName = radio.UniqueID.Substring(0, index + 1) + radio.GroupName; if ( radio.Checked && form[uniqueGroupName] != radio.ID ) --- 787,791 ---- { RadioButton radio = control as RadioButton; ! int index = radio.UniqueID.LastIndexOf(':'); string uniqueGroupName = radio.UniqueID.Substring(0, index + 1) + radio.GroupName; if ( radio.Checked && form[uniqueGroupName] != radio.ID ) *************** *** 653,657 **** if ( (ddlist.SelectedIndex == -1 && form[id] != null) || ddlist.SelectedValue != form[id] ) ! AjaxCallHelper.WriteSetFieldScript (id, ddlist.SelectedValue); } else if ( control is ListBox ) --- 822,826 ---- if ( (ddlist.SelectedIndex == -1 && form[id] != null) || ddlist.SelectedValue != form[id] ) ! AjaxCallHelper.WriteSetFieldScript (id, ddlist.SelectedValue); } else if ( control is ListBox ) *************** *** 707,711 **** else if ( control is RadioButtonList ) { ! RadioButtonList rblist = control as RadioButtonList; if ( rblist.SelectedIndex == -1 && form[id] != null ) { --- 876,880 ---- else if ( control is RadioButtonList ) { ! RadioButtonList rblist = control as RadioButtonList; if ( rblist.SelectedIndex == -1 && form[id] != null ) { *************** *** 725,729 **** AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=true;\r\n", String.Format("{0}_{1}", control.ClientID, rblist.SelectedIndex)); } ! } else if ( control is TextBox ) { --- 894,898 ---- AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=true;\r\n", String.Format("{0}_{1}", control.ClientID, rblist.SelectedIndex)); } ! } else if ( control is TextBox ) { *************** *** 934,938 **** // Increase script writing level because we want literal content to // be rendered before the child controls renderings ! AjaxCallHelper.IncreaseWritingLevel(); foreach (Control con in _removedControls) --- 1103,1107 ---- // Increase script writing level because we want literal content to // be rendered before the child controls renderings ! AjaxCallHelper.IncreaseWritingLevel(); foreach (Control con in _removedControls) *************** *** 989,1017 **** string htmlFingerprint = Util.GetFingerprint(html); ! if (htmlFingerprint != (string)_controlHtmlFingerprints[con] ! || ContainsUpdatedFormValues(html)) { // Its html rendering fingerprint has changed, // "reflect" its html on client. ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); ! _controlHtmlFingerprints[con] = htmlFingerprint; } - - //previous code, commented by Dion - // - //if (htmlFingerprint == (string)_controlHtmlFingerprints[con]) - //{ - // // Its html rendering fingerprint is the same, ignore the - // // html and compare the form elements that it contains - // // with those on client's page. - // ReflectContainedFormControls (con); - //} - //else - //{ - // // Its html rendering fingerprint has changed, - // // "reflect" its html on client. - // ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); - // _controlHtmlFingerprints[con] = htmlFingerprint; - //} } else --- 1158,1186 ---- string htmlFingerprint = Util.GetFingerprint(html); ! //previous code, commented by Argiris ! // ! //if (htmlFingerprint != (string)_controlHtmlFingerprints[con] ! // || ContainsUpdatedFormValues(html)) ! //{ ! // // Its html rendering fingerprint has changed, ! // // "reflect" its html on client. ! // ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); ! // _controlHtmlFingerprints[con] = htmlFingerprint; ! //} ! ! if (htmlFingerprint == (string)_controlHtmlFingerprints[con]) ! { ! // Its html rendering fingerprint is the same, ignore the ! // html and "reflect" the form elements that it contains ! // on client's page if they're different. ! ReflectUpdatedFormValues (html); ! } ! else { // Its html rendering fingerprint has changed, // "reflect" its html on client. ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); ! _controlHtmlFingerprints[con] = htmlFingerprint; } } else *************** *** 1031,1037 **** string literalhtml = sbLiteral.ToString(); string literalFingerprint = Util.GetFingerprint(literalhtml); ! if ( _controlState.LiteralFingerprint == literalFingerprint ) { ! ReflectLiteralFormControls(); } else --- 1200,1209 ---- string literalhtml = sbLiteral.ToString(); string literalFingerprint = Util.GetFingerprint(literalhtml); ! if ( literalFingerprint == _controlState.LiteralFingerprint ) { ! // Its html rendering fingerprint is the same, ignore the ! // html and "reflect" the form elements that it contains ! // on client's page if they're different. ! ReflectUpdatedFormValues (literalhtml); } else |
From: Dion O. <dol...@us...> - 2005-12-08 11:34:08
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20209/magicajax/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Small regex fix for <select> tag Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** AjaxPanel.cs 8 Dec 2005 01:43:11 -0000 1.30 --- AjaxPanel.cs 8 Dec 2005 11:33:50 -0000 1.31 *************** *** 498,510 **** // Check <select> tags // ! regEx = new System.Text.RegularExpressions.Regex("<select\\s.*?name=\"(?<name>[-\\w]+)\".*?(?<multiple>multiple=\"multiple\")?.*>.*?</select>", options); ! Regex regExOpt = new System.Text.RegularExpressions.Regex("<option\\s.*?(?<selected>selected=\"selected\")?.*?value=\"(?<value>.*?)\".*?>.*?</option>", options); ! matches = regEx.Matches(html); for (int i=0; i<matches.Count; i++) { ! Match match = matches[i]; ! string name = match.Groups["name"].Value; ! bool multiple = match.Groups["multiple"].Success; if (name != null) --- 498,519 ---- // Check <select> tags // ! Regex regExSelect = new System.Text.RegularExpressions.Regex("<select\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*>(?<options>.*?)</select>", options); ! Regex regExOption = new System.Text.RegularExpressions.Regex("<option\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*>.*?</option>", options); ! matches = regExSelect.Matches(html); for (int i=0; i<matches.Count; i++) { ! Match matchSelect = matches[i]; ! CaptureCollection attrnamesSelect = matchSelect.Groups["attrname"].Captures; ! CaptureCollection attrvaluesSelect = matchSelect.Groups["attrvalue"].Captures; ! Hashtable attrNameValuesSelect = new Hashtable(); ! for (int j = 0; j < attrnamesSelect.Count; j++) ! { ! attrNameValuesSelect.Add(attrnamesSelect[j].Value.ToLower(), attrvaluesSelect[j].Value); ! } ! ! string name = (string)attrNameValuesSelect["name"]; ! bool multiple = attrNameValuesSelect.ContainsKey("multiple"); ! bool isDropDown = !attrNameValuesSelect.ContainsKey("size"); if (name != null) *************** *** 512,529 **** string serverValue = null; ! //now match the options within this <select> tag ! MatchCollection matchesOpt = regExOpt.Matches(match.Value); ! for (int j = 0; j < matchesOpt.Count; j++) { ! Match matchOpt = matchesOpt[j]; ! string optValue = matchOpt.Groups["value"].Value; //TODO: check value encodings etc. ! bool optSelected = matchOpt.Groups["selected"].Success; ! if (optSelected) { ! serverValue += (serverValue == null ? string.Empty : ",") + optValue; ! if (!multiple) break; } } --- 521,555 ---- string serverValue = null; ! //now match the <option>s within this <select> tag ! MatchCollection matchesOption = regExOption.Matches(matchSelect.Groups["options"].Value); ! for (int j = 0; j < matchesOption.Count; j++) { ! Match matchOption = matchesOption[j]; ! CaptureCollection attrnamesOption = matchOption.Groups["attrname"].Captures; ! CaptureCollection attrvaluesOption = matchOption.Groups["attrvalue"].Captures; ! Hashtable attrNameValuesOption = new Hashtable(); ! for (int k = 0; k < attrnamesOption.Count; k++) ! { ! attrNameValuesOption.Add(attrnamesOption[k].Value.ToLower(), attrvaluesOption[k].Value); ! } ! ! string optValue = (string)attrNameValuesOption["value"]; //TODO: check value encodings etc. ! bool optSelected = attrNameValuesOption.ContainsKey("selected"); ! if (!multiple) { ! //for dropdowns: start with picking first item ! if (isDropDown && serverValue == null) ! serverValue = optValue; ! if (optSelected) ! { ! serverValue = optValue; break; + } + } + else if (optSelected) + { + serverValue += (serverValue == null ? string.Empty : ",") + optValue; } } |
From: Dion O. <dol...@us...> - 2005-12-08 01:43:19
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15699/magicajax/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Added the ContainsUpdatedFormValues(string html) method, that parses all form input controls from the html, and checks if their values were updated (i.e. different from the current Request.Form values) Note: not 100% tested yet Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** AjaxPanel.cs 5 Dec 2005 18:44:31 -0000 1.29 --- AjaxPanel.cs 8 Dec 2005 01:43:11 -0000 1.30 *************** *** 30,33 **** --- 30,34 ---- using System.Globalization; using System.Text; + using System.Text.RegularExpressions; namespace MagicAjax.UI.Controls *************** *** 422,425 **** --- 423,542 ---- /// <summary> + /// Parses all form input controls from the html, and checks if + /// their values were updated (i.e. different from the current Request.Form values) + /// </summary> + /// <param name="html"></param> + protected bool ContainsUpdatedFormValues(string html) + { + NameValueCollection form = Context.Request.Form; + RegexOptions options = RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Compiled; + + #region Check <input> tags + // + // Check <input> tags + // + Regex regEx = new System.Text.RegularExpressions.Regex("<input\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*/>", options); + MatchCollection matches = regEx.Matches(html); + for (int i=0; i<matches.Count; i++) + { + Match match = matches[i]; + CaptureCollection attrnames = match.Groups["attrname"].Captures; + CaptureCollection attrvalues = match.Groups["attrvalue"].Captures; + + Hashtable attrNameValues = new Hashtable(); + for (int j=0; j< attrnames.Count; j++) + { + attrNameValues.Add(attrnames[j].Value.ToLower(), attrvalues[j].Value); + } + + string type = (string)attrNameValues["type"]; + string name = (string)attrNameValues["name"]; + string value = attrNameValues.ContainsKey("value") ? (string)attrNameValues["value"] : string.Empty; + bool isChecked = attrNameValues.ContainsKey("checked"); + + if (type != null && name != null) + { + switch (type) + { + case "text": + case "password": + if (value != form[name]) + return true; + break; + case "checkbox": + if (isChecked != (form[name] != null)) + return true; + break; + case "radio": + if ((isChecked && form[name] != value) || (!isChecked && form[name] == value)) + return true; + break; + } + } + } + #endregion + + #region Check <textarea> tags + // + // Check <textarea> tags + // + regEx = new System.Text.RegularExpressions.Regex("<textarea\\s.*?name=\"(?<name>[-\\w]+)\".*?>(?<value>.*?)</textarea>", options); + matches = regEx.Matches(html); + for (int i=0; i<matches.Count; i++) + { + Match match = matches[i]; + string name = match.Groups["name"].Value; + string value = match.Groups["value"].Success ? match.Groups["value"].Value : string.Empty; + + if (value != form[name]) + return true; + } + #endregion + + #region Check <select> tags + // + // Check <select> tags + // + regEx = new System.Text.RegularExpressions.Regex("<select\\s.*?name=\"(?<name>[-\\w]+)\".*?(?<multiple>multiple=\"multiple\")?.*>.*?</select>", options); + Regex regExOpt = new System.Text.RegularExpressions.Regex("<option\\s.*?(?<selected>selected=\"selected\")?.*?value=\"(?<value>.*?)\".*?>.*?</option>", options); + matches = regEx.Matches(html); + for (int i=0; i<matches.Count; i++) + { + Match match = matches[i]; + + string name = match.Groups["name"].Value; + bool multiple = match.Groups["multiple"].Success; + + if (name != null) + { + string serverValue = null; + + //now match the options within this <select> tag + MatchCollection matchesOpt = regExOpt.Matches(match.Value); + for (int j = 0; j < matchesOpt.Count; j++) + { + Match matchOpt = matchesOpt[j]; + + string optValue = matchOpt.Groups["value"].Value; //TODO: check value encodings etc. + bool optSelected = matchOpt.Groups["selected"].Success; + + if (optSelected) + { + serverValue += (serverValue == null ? string.Empty : ",") + optValue; + if (!multiple) + break; + } + } + + if (serverValue != form[name]) + return true; + } + } + #endregion + + return false; + } + + /// <summary> /// Determines whether the AjaxPanel should treat the given control as a separate /// 'html holder' to compare and 'reflect' its html rendering. *************** *** 845,863 **** { string htmlFingerprint = Util.GetFingerprint(html); ! ! if (htmlFingerprint == (string)_controlHtmlFingerprints[con]) ! { ! // Its html rendering fingerprint is the same, ignore the ! // html and compare the form elements that it contains ! // with those on client's page. ! ReflectContainedFormControls (con); ! } ! else { // Its html rendering fingerprint has changed, // "reflect" its html on client. ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); ! _controlHtmlFingerprints[con] = htmlFingerprint; } } else --- 962,991 ---- { string htmlFingerprint = Util.GetFingerprint(html); ! ! if (htmlFingerprint != (string)_controlHtmlFingerprints[con] ! || ContainsUpdatedFormValues(html)) { // Its html rendering fingerprint has changed, // "reflect" its html on client. ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); ! _controlHtmlFingerprints[con] = htmlFingerprint; } + + //previous code, commented by Dion + // + //if (htmlFingerprint == (string)_controlHtmlFingerprints[con]) + //{ + // // Its html rendering fingerprint is the same, ignore the + // // html and compare the form elements that it contains + // // with those on client's page. + // ReflectContainedFormControls (con); + //} + //else + //{ + // // Its html rendering fingerprint has changed, + // // "reflect" its html on client. + // ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); + // _controlHtmlFingerprints[con] = htmlFingerprint; + //} } else |
From: Argiris K. <be...@us...> - 2005-12-06 01:58:06
|
Update of /cvsroot/magicajax/magicajax/CustomControls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1046/CustomControls Removed Files: AssemblyInfo.cs CustomControls.csproj Log Message: Removed CustomControls folder. For now... --- CustomControls.csproj DELETED --- --- AssemblyInfo.cs DELETED --- |
From: Argiris K. <be...@us...> - 2005-12-06 01:58:06
|
Update of /cvsroot/magicajax/magicajax/CustomControls/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1046/CustomControls/script Removed Files: AjaxLinkedPanelListScripts.js Log Message: Removed CustomControls folder. For now... --- AjaxLinkedPanelListScripts.js DELETED --- |
From: Argiris K. <be...@us...> - 2005-12-06 01:58:06
|
Update of /cvsroot/magicajax/magicajax/CustomControls/UI/Design In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1046/CustomControls/UI/Design Removed Files: AjaxCascadeTableDesigner.cs AjaxTabbedPanelDesigner.cs Log Message: Removed CustomControls folder. For now... --- AjaxTabbedPanelDesigner.cs DELETED --- --- AjaxCascadeTableDesigner.cs DELETED --- |
From: Argiris K. <be...@us...> - 2005-12-06 01:58:06
|
Update of /cvsroot/magicajax/magicajax/CustomControls/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1046/CustomControls/UI/Controls Removed Files: AjaxCascadeTable.cs AjaxLinkedPanelListControl.cs AjaxTabbedPanel.cs Log Message: Removed CustomControls folder. For now... --- AjaxTabbedPanel.cs DELETED --- --- AjaxLinkedPanelListControl.cs DELETED --- --- AjaxCascadeTable.cs DELETED --- |
From: Argiris K. <be...@us...> - 2005-12-06 01:55:11
|
Update of /cvsroot/magicajax/magicajax/CustomControls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv424/CustomControls Removed Files: Tag: STABLE AssemblyInfo.cs CustomControls.csproj Log Message: Removed the CustomControls folder. For now... --- CustomControls.csproj DELETED --- --- AssemblyInfo.cs DELETED --- |
From: Argiris K. <be...@us...> - 2005-12-06 01:55:11
|
Update of /cvsroot/magicajax/magicajax/CustomControls/UI/Design In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv424/CustomControls/UI/Design Removed Files: Tag: STABLE AjaxCascadeTableDesigner.cs AjaxTabbedPanelDesigner.cs Log Message: Removed the CustomControls folder. For now... --- AjaxTabbedPanelDesigner.cs DELETED --- --- AjaxCascadeTableDesigner.cs DELETED --- |
From: Argiris K. <be...@us...> - 2005-12-06 01:55:11
|
Update of /cvsroot/magicajax/magicajax/CustomControls/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv424/CustomControls/UI/Controls Removed Files: Tag: STABLE AjaxCascadeTable.cs AjaxLinkedPanelListControl.cs AjaxTabbedPanel.cs Log Message: Removed the CustomControls folder. For now... --- AjaxTabbedPanel.cs DELETED --- --- AjaxLinkedPanelListControl.cs DELETED --- --- AjaxCascadeTable.cs DELETED --- |
From: Argiris K. <be...@us...> - 2005-12-06 01:55:10
|
Update of /cvsroot/magicajax/magicajax/CustomControls/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv424/CustomControls/script Removed Files: Tag: STABLE AjaxLinkedPanelListScripts.js Log Message: Removed the CustomControls folder. For now... --- AjaxLinkedPanelListScripts.js DELETED --- |
From: Argiris K. <be...@us...> - 2005-12-05 18:44:39
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13470/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: If the html fingerprint of a 'html holder' doesn't change, AjaxPanel 'reflects' the form controls to the client. Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** AjaxPanel.cs 4 Dec 2005 03:25:15 -0000 1.28 --- AjaxPanel.cs 5 Dec 2005 18:44:31 -0000 1.29 *************** *** 23,26 **** --- 23,27 ---- using System.ComponentModel; using System.Collections; + using System.Collections.Specialized; using System.Web; using System.Web.UI; *************** *** 274,278 **** protected override void AddedControl(Control control, int index) { ! if ( control is WebControl ) { if ( IsPageNoStoreMode ) --- 275,279 ---- protected override void AddedControl(Control control, int index) { ! if ( IsHtmlHolder(control) ) { if ( IsPageNoStoreMode ) *************** *** 299,303 **** protected override void RemovedControl(Control control) { ! if ( control is WebControl ) { if (_addedControls.Contains(control)) --- 300,304 ---- protected override void RemovedControl(Control control) { ! if ( IsHtmlHolder(control) ) { if (_addedControls.Contains(control)) *************** *** 334,341 **** Control con = Controls[i]; ! // Put inside span tag only WebControls ! bool isWebControl = ( con is WebControl ); ! if ( isWebControl ) { writer.WriteBeginTag ("span"); --- 335,342 ---- Control con = Controls[i]; ! // Put inside span tag only html holder controls ! bool isHtmlHolder = IsHtmlHolder(con); ! if ( isHtmlHolder ) { writer.WriteBeginTag ("span"); *************** *** 354,358 **** string html = sb.ToString(); ! if ( isWebControl ) { _controlHtmlFingerprints[con] = Util.GetFingerprint(html); --- 355,359 ---- string html = sb.ToString(); ! if ( isHtmlHolder ) { _controlHtmlFingerprints[con] = Util.GetFingerprint(html); *************** *** 401,405 **** foreach (Control con in this.Controls) { ! if ( con is WebControl ) { if (_controlState.ControlHtmlFingerprints.ContainsKey(con.ClientID)) --- 402,406 ---- foreach (Control con in this.Controls) { ! if ( IsHtmlHolder(con) ) { if (_controlState.ControlHtmlFingerprints.ContainsKey(con.ClientID)) *************** *** 420,423 **** --- 421,690 ---- } + /// <summary> + /// Determines whether the AjaxPanel should treat the given control as a separate + /// 'html holder' to compare and 'reflect' its html rendering. + /// </summary> + /// <remarks> + /// Only WebControls, excluding RenderedByScriptControls, are considered html holders. + /// </remarks> + /// <param name="control"></param> + /// <returns></returns> + protected virtual bool IsHtmlHolder (Control control) + { + return ( control is WebControl && !(control is RenderedByScriptControl) ); + } + + protected void ReflectContainedFormControls (Control container) + { + ArrayList elems = new ArrayList(); + if ( container is IPostBackDataHandler ) + elems.Add (container); + elems.AddRange (Util.GetChildControlsOfType(container, typeof(IPostBackDataHandler), typeof(RenderedByScriptControl), true)); + + for (int i=0; i < elems.Count; i++) + ReflectFormControl (elems[i] as Control); + } + + protected void ReflectLiteralFormControls() + { + for (int i=0; i < this.Controls.Count; i++) + { + if ( ! IsHtmlHolder(this.Controls[i]) ) + ReflectContainedFormControls (this.Controls[i]); + } + } + + #region ReflectFormControl + /// <summary> + /// Compares the value of the form control with the value of the client's + /// form element and sends javascript command to corrent the client's element + /// if necessary. + /// </summary> + /// <param name="control"></param> + protected virtual void ReflectFormControl (Control control) + { + NameValueCollection form = Context.Request.Form; + + if ( control is WebControl ) + { + #region Reflecting for WebControls + + string id = control.UniqueID; + + if ( control is RadioButton ) + { + RadioButton radio = control as RadioButton; + int index = radio.UniqueID.LastIndexOf(':'); + string uniqueGroupName = radio.UniqueID.Substring(0, index + 1) + radio.GroupName; + if ( radio.Checked && form[uniqueGroupName] != radio.ID ) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=true;\r\n", control.ClientID); + } + else if ( !radio.Checked && form[uniqueGroupName] == radio.ID ) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=false;\r\n", control.ClientID); + } + } + else if ( control is CheckBox ) + { + if ( !(control.Parent is CheckBoxList) ) + { + CheckBox chkbox = control as CheckBox; + if ( chkbox.Checked != (form[id] != null) ) + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked={1};\r\n", id, (chkbox.Checked) ? "true" : "false"); + } + } + else if ( control is CheckBoxList ) + { + CheckBoxList chklist = control as CheckBoxList; + for (int i=0; i < chklist.Items.Count; i++) + { + string itemid = String.Format("{0}:{1}", id, i); + if ( chklist.Items[i].Selected != (form[itemid] != null) ) + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked={1};\r\n", itemid, (chklist.Items[i].Selected) ? "true" : "false"); + } + } + else if ( control is DropDownList ) + { + DropDownList ddlist = control as DropDownList; + if ( (ddlist.SelectedIndex == -1 && form[id] != null) + || ddlist.SelectedValue != form[id] ) + AjaxCallHelper.WriteSetFieldScript (id, ddlist.SelectedValue); + } + else if ( control is ListBox ) + { + ListBox lstbox = control as ListBox; + if ( ListSelectionMode.Single == lstbox.SelectionMode ) + { + if ( (lstbox.SelectedIndex == -1 && form[id] != null) + || lstbox.SelectedValue != form[id] ) + AjaxCallHelper.WriteSetFieldScript (id, lstbox.SelectedValue); + } + else + { + string[] selections = form.GetValues(id); + bool elemWritten = false; + + // Make selections + for (int i=0; i < lstbox.Items.Count; i++) + { + if (lstbox.Items[i].Selected && Array.IndexOf(selections, lstbox.Items[i].Value) == -1) + { + if ( ! elemWritten ) + { + AjaxCallHelper.WriteFormat ("elem=document.forms[0][\"{0}\"];\r\n", id); + elemWritten = true; + } + AjaxCallHelper.WriteFormat ("elem.options[{0}].selected=true;\r\n", i); + } + } + + // Make unselections + for (int i=0; i < selections.Length; i++) + { + for (int itemi=0; itemi < lstbox.Items.Count; itemi++) + { + if ( lstbox.Items[itemi].Value == selections[i] ) + { + if ( ! lstbox.Items[itemi].Selected ) + { + if ( ! elemWritten ) + { + AjaxCallHelper.WriteFormat ("elem=document.forms[0][\"{0}\"];\r\n", id); + elemWritten = true; + } + AjaxCallHelper.WriteFormat ("elem.options[{0}].selected=false;\r\n", itemi); + } + break; + } + } + } + } + } + else if ( control is RadioButtonList ) + { + RadioButtonList rblist = control as RadioButtonList; + if ( rblist.SelectedIndex == -1 && form[id] != null ) + { + // Clear selection + for (int i=0; i < rblist.Items.Count; i++) + { + if (rblist.Items[i].Value == form[id]) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=false;\r\n", String.Format("{0}_{1}", control.ClientID, i)); + break; + } + } + } + else if ( rblist.SelectedIndex != -1 && rblist.SelectedValue != form[id] ) + { + // Make selection + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=true;\r\n", String.Format("{0}_{1}", control.ClientID, rblist.SelectedIndex)); + } + } + else if ( control is TextBox ) + { + TextBox txtbox = control as TextBox; + if ( txtbox.Text != form[id] ) + AjaxCallHelper.WriteSetFieldScript (id, txtbox.Text); + } + + #endregion + } + else if ( control is HtmlControl ) + { + #region Reflecting for HtmlControls + + if ( control is HtmlInputCheckBox ) + { + HtmlInputCheckBox chkbox = control as HtmlInputCheckBox; + if ( chkbox.Checked != (form[chkbox.Name] != null) ) + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked={1};\r\n", chkbox.Name, (chkbox.Checked) ? "true" : "false"); + } + else if ( control is HtmlInputRadioButton ) + { + HtmlInputRadioButton radio = control as HtmlInputRadioButton; + if ( radio.Name != String.Empty ) + { + int index = radio.UniqueID.LastIndexOf(':'); + string uniqueName = radio.UniqueID.Substring(0, index + 1) + radio.Name; + if ( radio.Checked && form[uniqueName] != radio.ID ) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=true;\r\n", control.ClientID); + } + else if ( !radio.Checked && form[uniqueName] == radio.ID ) + { + AjaxCallHelper.WriteFormat ("document.forms[0][\"{0}\"].checked=false;\r\n", control.ClientID); + } + } + } + else if ( control is HtmlInputText ) + { + HtmlInputText txtbox = control as HtmlInputText; + if ( txtbox.Value != form[txtbox.Name] ) + AjaxCallHelper.WriteSetFieldScript (txtbox.Name, txtbox.Value); + } + else if ( control is HtmlSelect ) + { + HtmlSelect sel = control as HtmlSelect; + if ( ! sel.Multiple ) + { + if ( (sel.SelectedIndex == -1 && form[sel.Name] != null) + || sel.Value != form[sel.Name] ) + AjaxCallHelper.WriteSetFieldScript (sel.Name, sel.Value); + } + else + { + string[] selections = form.GetValues(sel.Name); + bool elemWritten = false; + + // Make selections + for (int i=0; i < sel.Items.Count; i++) + { + if (sel.Items[i].Selected && Array.IndexOf(selections, sel.Items[i].Value) == -1) + { + if ( ! elemWritten ) + { + AjaxCallHelper.WriteFormat ("elem=document.forms[0][\"{0}\"];\r\n", sel.Name); + elemWritten = true; + } + AjaxCallHelper.WriteFormat ("elem.options[{0}].selected=true;\r\n", i); + } + } + + // Make unselections + for (int i=0; i < selections.Length; i++) + { + for (int itemi=0; itemi < sel.Items.Count; itemi++) + { + if ( sel.Items[itemi].Value == selections[i] ) + { + if ( ! sel.Items[itemi].Selected ) + { + if ( ! elemWritten ) + { + AjaxCallHelper.WriteFormat ("elem=document.forms[0][\"{0}\"];\r\n", sel.Name); + elemWritten = true; + } + AjaxCallHelper.WriteFormat ("elem.options[{0}].selected=false;\r\n", itemi); + } + break; + } + } + } + } + } + else if ( control is HtmlTextArea ) + { + HtmlTextArea txtbox = control as HtmlTextArea; + if ( txtbox.Value != form[txtbox.Name] ) + AjaxCallHelper.WriteSetFieldScript (txtbox.Name, txtbox.Value); + } + + #endregion + } + } + #endregion + #region override PutTagOnPageForAjaxCall /// <summary> *************** *** 479,486 **** Control con = Controls[i]; ! // Put inside span tag only WebControls ! bool isWebControl = ( con is WebControl ); ! if ( isWebControl ) { fullwriter.WriteBeginTag ("span"); --- 746,753 ---- Control con = Controls[i]; ! // Put inside span tag only html holder controls ! bool isHtmlHolder = IsHtmlHolder(con); ! if ( isHtmlHolder ) { fullwriter.WriteBeginTag ("span"); *************** *** 498,502 **** string html = sb.ToString(); ! if ( isWebControl ) { fullwriter.WriteEndTag ("span"); --- 765,769 ---- string html = sb.ToString(); ! if ( isHtmlHolder ) { fullwriter.WriteEndTag ("span"); *************** *** 535,542 **** Control con = Controls[i]; ! // Only WebControls are inside a span tag ! bool isWebControl = ( con is WebControl ); ! if ( isWebControl ) { literalwriter.WriteBeginTag ("span"); --- 802,809 ---- Control con = Controls[i]; ! // Only html holder controls are inside a span tag ! bool isHtmlHolder = IsHtmlHolder(con); ! if ( isHtmlHolder ) { literalwriter.WriteBeginTag ("span"); *************** *** 550,554 **** sbFull.Length = sb.Length = 0; ! if ( isWebControl && _addedControls.Contains(con) ) { // It's a new control, create it on the client at the appropriate place. --- 817,821 ---- sbFull.Length = sb.Length = 0; ! if ( isHtmlHolder && _addedControls.Contains(con) ) { // It's a new control, create it on the client at the appropriate place. *************** *** 575,585 **** html = sb.ToString(); ! if ( isWebControl ) { string htmlFingerprint = Util.GetFingerprint(html); ! // If it's html rendering fingerprint is the same, ignore it. ! if (htmlFingerprint != (string)_controlHtmlFingerprints[con]) { ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); _controlHtmlFingerprints[con] = htmlFingerprint; --- 842,860 ---- html = sb.ToString(); ! if ( isHtmlHolder ) { string htmlFingerprint = Util.GetFingerprint(html); ! if (htmlFingerprint == (string)_controlHtmlFingerprints[con]) ! { ! // Its html rendering fingerprint is the same, ignore the ! // html and compare the form elements that it contains ! // with those on client's page. ! ReflectContainedFormControls (con); ! } ! else { + // Its html rendering fingerprint has changed, + // "reflect" its html on client. ExtendedWriteSetHtmlOfElementScript(html, GetAjaxElemID(con)); _controlHtmlFingerprints[con] = htmlFingerprint; *************** *** 602,606 **** string literalhtml = sbLiteral.ToString(); string literalFingerprint = Util.GetFingerprint(literalhtml); ! if ( _controlState.LiteralFingerprint != literalFingerprint ) { ExtendedWriteSetHtmlOfElementScript (literalhtml, this.ClientID); --- 877,885 ---- string literalhtml = sbLiteral.ToString(); string literalFingerprint = Util.GetFingerprint(literalhtml); ! if ( _controlState.LiteralFingerprint == literalFingerprint ) ! { ! ReflectLiteralFormControls(); ! } ! else { ExtendedWriteSetHtmlOfElementScript (literalhtml, this.ClientID); *************** *** 765,769 **** private void InitValidators() { ! ArrayList validators = Util.GetChildControlsOfType(this, typeof(BaseValidator), true); foreach (BaseValidator validator in validators) { --- 1044,1048 ---- private void InitValidators() { ! ArrayList validators = Util.GetChildControlsOfType(this, typeof(BaseValidator), typeof(RenderedByScriptControl), true); foreach (BaseValidator validator in validators) { *************** *** 776,780 **** private void DisableClientValidators() { ! ArrayList validators = Util.GetChildControlsOfType(this, typeof(BaseValidator), true); foreach (BaseValidator validator in validators) { --- 1055,1059 ---- private void DisableClientValidators() { ! ArrayList validators = Util.GetChildControlsOfType(this, typeof(BaseValidator), typeof(RenderedByScriptControl), true); foreach (BaseValidator validator in validators) { |