From: Dion O. <dol...@us...> - 2006-01-23 01:28:52
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27153/magicajax/Core Modified Files: AjaxCallHelper.cs MagicAjaxModule.cs Util.cs Log Message: Fix for .NET 1,1 Stylesheet updates on callback Index: AjaxCallHelper.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/AjaxCallHelper.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** AjaxCallHelper.cs 20 Jan 2006 01:35:56 -0000 1.20 --- AjaxCallHelper.cs 23 Jan 2006 01:28:41 -0000 1.21 *************** *** 307,310 **** --- 307,324 ---- } + public static void WriteAddHeaderElementScript(string tagName, string innerText, NameValueCollection attributes) + { + StringBuilder sbuilder = new StringBuilder("new Array("); + for (int i = 0; i < attributes.Count; i++) + { + if (i > 0) + sbuilder.Append(","); + sbuilder.AppendFormat("\"{0}\",\"{1}\"", attributes.Keys[i], attributes[i]); + } + sbuilder.Append(")"); + + Write(String.Format("AJAXCbo.AddHeaderElement(\"{0}\",{1},{2});\r\n", tagName, EncodeString(innerText), sbuilder.ToString())); + } + /// <summary> /// Produces the javascript that will add a script element to the page. Index: Util.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/Util.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Util.cs 20 Jan 2006 01:35:56 -0000 1.24 --- Util.cs 23 Jan 2006 01:28:41 -0000 1.25 *************** *** 37,40 **** --- 37,41 ---- public const string ScriptPattern = "<script.[^>]*>"; public const string FormElementPattern = @"<(?<tag>input|textarea|select)\s+(?<attribute>(?<attrname>[-\w]+)=((""|')(?<attrvalue>.*?)(""|')\s*|(?<attrvalue>[-\w]+)\s*))*.*?(/>|>(?<inner>.*?)</\k'tag'>)"; + public const string HeadElementPattern = @"<(?<tag>title|style|link)\s*(?<attribute>(?<attrname>[-\w]+)=((""|')(?<attrvalue>.*?)(""|')\s*|(?<attrvalue>[-\w]+)\s*))*.*?(/>|>[\r\n\t]*(?<inner>.*?)[\r\n]*</\k'tag'>)"; #region Global Regular Expressions *************** *** 44,48 **** public static Regex FormElementOptionSelectedRegEx = new Regex(@"<option.*?(?<selected>selected=(""|'|)selected(""|'|)(\s+|(?=>))).*?>", _options); public static Regex ScriptPatternRegEx = new Regex(Util.ScriptPattern, RegexOptions.IgnoreCase); ! public static Regex ScriptTagsRegEx = new Regex("<script\\s((?<attrname>[-\\w]+)=\"(?<attrvalue>.*?)\"\\s?)*\\s*>(?<script>.*?)</script>", _options); #endregion --- 45,50 ---- public static Regex FormElementOptionSelectedRegEx = new Regex(@"<option.*?(?<selected>selected=(""|'|)selected(""|'|)(\s+|(?=>))).*?>", _options); public static Regex ScriptPatternRegEx = new Regex(Util.ScriptPattern, RegexOptions.IgnoreCase); ! public static Regex ScriptTagsRegEx = new Regex("<script\\s((?<attrname>[-\\w]+)=[\"'](?<attrvalue>.*?)[\"']\\s?)*\\s*>(?<script>.*?)</script>", _options); ! public static Regex HeaderTagsRegEx = new Regex(HeadElementPattern, _options); #endregion *************** *** 270,275 **** /// Copies all fields (private and public) from the source object to /// the destination object thereby performing shallow copy - /// Unlike shallow copy however, the objects do not need to be of the same type - /// and destination can be a decendant of source in the class heirarchy /// </summary> /// <param name="destination">object to copy fields on</param> --- 272,275 ---- Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** MagicAjaxModule.cs 20 Jan 2006 01:35:56 -0000 1.59 --- MagicAjaxModule.cs 23 Jan 2006 01:28:41 -0000 1.60 *************** *** 463,472 **** Page currentPage = HttpContext.Current.Handler as Page; - #if NET_2_0 // On Page-init, we're going to replace the regular HTMLForm control with an AjaxHMTLForm ! // For now, only supported for .NET 2.0 ! if (currentPage != null) ! currentPage.Init += new EventHandler(currentPage_Init); ! #endif // Continue only if it is a postback or an AjaxCall --- 463,469 ---- Page currentPage = HttpContext.Current.Handler as Page; // On Page-init, we're going to replace the regular HTMLForm control with an AjaxHMTLForm ! //if (currentPage != null) ! // currentPage.Init += new EventHandler(currentPage_Init); // Continue only if it is a postback or an AjaxCall *************** *** 482,485 **** --- 479,483 ---- } #endif + string configState = _request.Form["__MAGICAJAX_CONFIG"]; if (configState != null) *************** *** 614,658 **** ! /// <summary> ! /// On Page init, we're going to we're going to replace ! /// the regular HTMLForm control with our own AjaxHMTLForm. ! /// This way we can implement a custom rendering of the form, ! /// which reflects added scripts and hidden fields on Ajax callbacks ! /// </summary> ! /// <param name="sender">The current page</param> ! /// <param name="e"></param> ! void currentPage_Init(object sender, EventArgs e) ! { ! Page thePage = (Page)sender; ! if (thePage != null) ! { ! HtmlForm oldFrm = (HtmlForm)Util.GetPrivateField(thePage, typeof(Page), "_form"); ! AjaxHtmlForm newFrm = new AjaxHtmlForm(); ! // Copy all properties over ! Util.ForceShallowCopyOnObject(newFrm, oldFrm); ! // when adding a control - the framework will try to disconnect it from its parent ! // so we better make sure it it has no parent. ! Util.SetPrivateField(newFrm, typeof(Control), "_parent", null); ! Util.SetPrivateField(thePage, typeof(Page), "_form", newFrm); ! // Now replace the current Form control by our own ! Control hostingControl = (Control)thePage; ! #if NET_2_0 ! if (thePage.Master != null) ! { ! MasterPage master = thePage.Master; ! while (master.Master != null) ! master = master.Master; ! hostingControl = (Control)master; ! } ! #endif ! int formIndex = hostingControl.Controls.IndexOf(oldFrm); ! hostingControl.Controls.RemoveAt(formIndex); ! hostingControl.Controls.AddAt(formIndex, newFrm); ! } ! } /// <summary> --- 612,667 ---- ! // /// <summary> ! // /// On Page init, we're going to we're going to replace ! // /// the regular HTMLForm control with our own AjaxHMTLForm. ! // /// This way we can implement a custom rendering of the form, ! // /// which reflects added scripts and hidden fields on Ajax callbacks ! // /// </summary> ! // /// <param name="sender">The current page</param> ! // /// <param name="e"></param> ! // void currentPage_Init(object sender, EventArgs e) ! // { ! // Page thePage = (Page)sender; ! // if (thePage != null) ! // { ! // HtmlForm oldFrm = (HtmlForm)Util.GetPrivateField(thePage, typeof(Page), "_form"); ! // //thePage.Form.SetRenderMethodDelegate ! // AjaxHtmlForm newFrm = new AjaxHtmlForm(); ! ! // // Copy all properties over ! // Util.ForceShallowCopyOnObject(newFrm, oldFrm); ! ! // // when adding a control - the framework will try to disconnect it from its parent ! // // so we better make sure it it has no parent. ! // Util.SetPrivateField(newFrm, typeof(Control), "_parent", null); ! // Util.SetPrivateField(thePage, typeof(Page), "_form", newFrm); ! // // Now replace the current Form control by our own ! // Control hostingControl = (Control)thePage; ! //#if NET_2_0 ! // if (thePage.Master != null) ! // { ! // MasterPage master = thePage.Master; ! // while (master.Master != null) ! // master = master.Master; ! // hostingControl = (Control)master; ! // } ! //#else ! // object readOnlyErrorMsg = Util.GetPrivateField(hostingControl.Controls, typeof(ControlCollection), "_readOnlyErrorMsg"); ! // Util.SetPrivateField(hostingControl.Controls, typeof(ControlCollection), "_readOnlyErrorMsg", null); ! //#endif ! ! // int formIndex = hostingControl.Controls.IndexOf(oldFrm); ! // hostingControl.Controls.RemoveAt(formIndex); ! // hostingControl.Controls.AddAt(formIndex, newFrm); ! ! //#if !NET_2_0 ! // Util.SetPrivateField(hostingControl.Controls, typeof(ControlCollection), "_readOnlyErrorMsg", readOnlyErrorMsg); ! //#endif ! // } ! // } /// <summary> |