From: Argiris K. <be...@us...> - 2005-11-20 13:46:36
|
Update of /cvsroot/magicajax/magicajax/Core/UI/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29341/Core/UI/Controls Modified Files: AjaxPanel.cs Log Message: Fixed some id mismatch bugs. Index: AjaxPanel.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/UI/Controls/AjaxPanel.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** AjaxPanel.cs 20 Nov 2005 08:47:30 -0000 1.17 --- AjaxPanel.cs 20 Nov 2005 13:46:28 -0000 1.18 *************** *** 269,272 **** --- 269,280 ---- protected override void AddedControl(Control control, int index) { + if ( IsPageNoStoreMode ) + { + // If the ID of the added control is null, find a unique id manually, + // or else the default naming order may cause mismatches. + if (control.ID == null || control.ID == String.Empty) + control.ID = FindUniqueID(); + } + _addedControls.Add (control); base.AddedControl (control, index); *************** *** 383,387 **** { // The control is removed. Add a control with the same id ! // so that DoScriptRendering "removes" it from page if ( clientID.StartsWith (this.ClientID) ) { --- 391,395 ---- { // The control is removed. Add a control with the same id ! // so that RenderByScript "removes" it from page if ( clientID.StartsWith (this.ClientID) ) { *************** *** 460,464 **** _controlHtmls.Remove(con); ! AjaxCallHelper.WriteRemoveElementScript (ClientID, GetAjaxElemID(con)); } --- 468,472 ---- _controlHtmls.Remove(con); ! AjaxCallHelper.WriteRemoveElementScript (ClientID, GetAjaxElemID(ClientID + "_" + con.ClientID)); } *************** *** 770,773 **** --- 778,806 ---- #endregion + #region FindUniqueID + /// <summary> + /// Finds an ID that no other AjaxPanel's child control has. + /// </summary> + /// <returns></returns> + private string FindUniqueID() + { + string prefix = "_ajaxctl"; + string id; + for (int num=0; ; num++) + { + id = prefix + num; + int i; + for (i=0; i < this.Controls.Count; i++) + if (this.Controls[i].ID == id) + break; + + if (i == this.Controls.Count) + break; + } + + return id; + } + #endregion + #region GetAjaxElemID /// <summary> *************** *** 776,783 **** /// <param name="control"></param> /// <returns></returns> ! private static string GetAjaxElemID(Control control) { return control.ClientID + "$ajaxdest"; } #endregion --- 809,820 ---- /// <param name="control"></param> /// <returns></returns> ! private string GetAjaxElemID(Control control) { return control.ClientID + "$ajaxdest"; } + private string GetAjaxElemID(string clientID) + { + return clientID + "$ajaxdest"; + } #endregion |