Author: igorz
Date: 2007-09-02 10:49:53 -0400 (Sun, 02 Sep 2007)
New Revision: 85196
Modified:
trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptComponentDescriptor.cs
trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptDescriptor.cs
trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs
Log:
added support for multi form environment
Modified:
trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptComponentDescriptor.cs
===================================================================
---
trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptComponentDescriptor.cs
2007-09-02 14:41:16 UTC (rev 85195)
+++
trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptComponentDescriptor.cs
2007-09-02 14:49:53 UTC (rev 85196)
@@ -142,10 +142,18 @@
}
protected internal override string GetScript () {
- if (String.IsNullOrEmpty (ElementIDInternal))
- return String.Format ("$create({0}, {1}, {2},
{3});", Type, GetSerializedProperties (), GetSerializedEvents (),
GetSerializedReferences ());
- else
- return String.Format ("$create({0}, {1}, {2},
{3}, $get(\"{4}\"));", Type, GetSerializedProperties (), GetSerializedEvents
(), GetSerializedReferences (), ElementIDInternal);
+ if (String.IsNullOrEmpty (FormID)) {
+ if (String.IsNullOrEmpty (ElementIDInternal))
+ return String.Format ("$create({0},
{1}, {2}, {3});", Type, GetSerializedProperties (), GetSerializedEvents (),
GetSerializedReferences ());
+ else
+ return String.Format ("$create({0},
{1}, {2}, {3}, $get(\"{4}\"));", Type, GetSerializedProperties (),
GetSerializedEvents (), GetSerializedReferences (), ElementIDInternal);
+ }
+ else {
+ if (String.IsNullOrEmpty (ElementIDInternal))
+ return String.Format
("$create($get(\"{0}\"), {1}, {2}, {3}, {4});", FormID, Type,
GetSerializedProperties (), GetSerializedEvents (), GetSerializedReferences ());
+ else
+ return String.Format
("$create($get(\"{0}\"), {1}, {2}, {3}, {4}, $get(\"{5}\"));", FormID, Type,
GetSerializedProperties (), GetSerializedEvents (), GetSerializedReferences (),
ElementIDInternal);
+ }
}
internal static string SerializeDictionary (Dictionary<string,
string> dictionary) {
Modified:
trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptDescriptor.cs
===================================================================
--- trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptDescriptor.cs
2007-09-02 14:41:16 UTC (rev 85195)
+++ trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptDescriptor.cs
2007-09-02 14:49:53 UTC (rev 85196)
@@ -35,8 +35,15 @@
{
public abstract class ScriptDescriptor
{
+ string _formID;
+
protected ScriptDescriptor () { }
protected internal abstract string GetScript ();
+
+ internal string FormID {
+ get { return _formID; }
+ set { _formID = value; }
+ }
}
}
Modified: trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs
===================================================================
--- trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs
2007-09-02 14:41:16 UTC (rev 85195)
+++ trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs
2007-09-02 14:49:53 UTC (rev 85196)
@@ -453,6 +453,9 @@
sb.AppendLine ();
for (int i = 0; i <
_disposeScripts.Count; i++) {
DisposeScriptEntry entry =
_disposeScripts [i];
+ if (IsMultiForm)
+ sb.Append
("Sys.WebForms.PageRequestManager.getInstance($get(\"" + Page.Form.ClientID +
"\"))._registerDisposeScript(\"");
+ else
sb.Append
("Sys.WebForms.PageRequestManager.getInstance()._registerDisposeScript(\"");
sb.Append
(entry.UpdatePanel.ClientID);
sb.Append ("\", ");
@@ -481,6 +484,16 @@
ajaxWebFormsScript.NotifyScriptLoaded = false;
OnResolveScriptReference (new ScriptReferenceEventArgs
(ajaxWebFormsScript));
+ ScriptReference ajaxExtensionScript = null;
+ ScriptReference ajaxWebFormsExtensionScript = null;
+ if (IsMultiForm) {
+ ajaxExtensionScript = new ScriptReference
("MicrosoftAjaxExtension.js", String.Empty);
+ OnResolveScriptReference (new
ScriptReferenceEventArgs (ajaxExtensionScript));
+
+ ajaxWebFormsExtensionScript = new
ScriptReference ("MicrosoftAjaxWebFormsExtension.js", String.Empty);
+ OnResolveScriptReference (new
ScriptReferenceEventArgs (ajaxWebFormsExtensionScript));
+ }
+
foreach (ScriptReferenceEntry script in
GetScriptReferences ()) {
OnResolveScriptReference (new
ScriptReferenceEventArgs (script.ScriptReference));
if (!IsInAsyncPostBack || (script.Control !=
this && HasBeenRendered (script.Control))) {
@@ -490,10 +503,14 @@
}
}
- // Register Ajax framework script.
- RegisterScriptReference (ajaxScript, true);
+ if (!IsInAsyncPostBack) {
+ // Register Ajax framework script.
+ RegisterScriptReference (ajaxScript, true);
+ if (IsMultiForm) {
+ RegisterScriptReference
(ajaxExtensionScript, true);
+ RegisterClientScriptBlock (this, typeof
(ScriptManager), "Sys.Application",
"\nSys.Application._initialize(document.getElementById('" + Page.Form.ClientID
+ "'));\n", true);
+ }
- if (!IsInAsyncPostBack) {
StringBuilder sb = new StringBuilder ();
sb.AppendLine ("if (typeof(Sys) ===
'undefined') throw new Error('ASP.NET Ajax client-side framework failed to
load.');");
@@ -510,10 +527,13 @@
sb.AppendLine
("Sys.Services.AuthenticationService.set_path('" + ResolveUrl
(_authenticationService.Path) + "');");
RegisterClientScriptBlock (this, typeof
(ScriptManager), "Framework", sb.ToString (), true);
+
+ RegisterScriptReference (ajaxWebFormsScript,
true);
+
+ if (IsMultiForm)
+ RegisterScriptReference
(ajaxWebFormsExtensionScript, true);
}
- RegisterScriptReference (ajaxWebFormsScript, true);
-
// Register Scripts
if (_scriptToRegister != null)
for (int i = 0; i < _scriptToRegister.Count;
i++)
@@ -533,10 +553,28 @@
}
// Register startup script
+ if (IsMultiForm)
+ RegisterStartupScript (this, typeof
(ExtenderControl), "Sys.Application.initialize();",
"Sys.Application.getInstance($get(\"" + Page.Form.ClientID +
"\")).initialize();\n", true);
+ else
RegisterStartupScript (this, typeof
(ExtenderControl), "Sys.Application.initialize();",
"Sys.Application.initialize();\n", true);
}
}
+#if TARGET_J2EE
+ bool IsMultiForm {
+ get {
+ Mainsoft.Web.Configuration.PagesSection
pageSection = (Mainsoft.Web.Configuration.PagesSection)
WebConfigurationManager.GetSection ("mainsoft.web/pages");
+ if (pageSection != null)
+ return pageSection.MultiForm;
+ return false;
+ }
+ }
+#else
+ bool IsMultiForm {
+ get { return false; }
+ }
+#endif
+
static bool HasBeenRendered (Control control) {
if (control == null)
return false;
@@ -858,6 +896,11 @@
StringBuilder sb = new StringBuilder ();
foreach (ScriptDescriptor scriptDescriptor in
scriptDescriptors) {
+ if (IsMultiForm) {
+ scriptDescriptor.FormID =
Page.Form.ClientID;
+ sb.AppendLine
("Sys.Application.getInstance($get(\"" + Page.Form.ClientID +
"\")).add_init(function() {");
+ }
+ else
sb.AppendLine
("Sys.Application.add_init(function() {");
sb.AppendLine (scriptDescriptor.GetScript ());
sb.AppendLine ("});");
@@ -930,6 +973,9 @@
writer.WriteLine ("<script
type=\"text/javascript\">");
writer.WriteLine ("//<![CDATA[");
writer.WriteLine
("Sys.WebForms.PageRequestManager._initialize('{0}',
document.getElementById('{1}'));", UniqueID, Page.Form.ClientID);
+ if (IsMultiForm)
+ writer.WriteLine
("Sys.WebForms.PageRequestManager.getInstance($get(\"{0}\"))._updateControls([{1}],
[{2}], [{3}], {4});", Page.Form.ClientID, FormatUpdatePanelIDs (_updatePanels,
true), FormatListIDs (_asyncPostBackControls, true), FormatListIDs
(_postBackControls, true), AsyncPostBackTimeout);
+ else
writer.WriteLine
("Sys.WebForms.PageRequestManager.getInstance()._updateControls([{0}], [{1}],
[{2}], {3});", FormatUpdatePanelIDs (_updatePanels, true), FormatListIDs
(_asyncPostBackControls, true), FormatListIDs (_postBackControls, true),
AsyncPostBackTimeout);
writer.WriteLine ("//]]");
writer.WriteLine ("</script>");
@@ -1074,7 +1120,8 @@
WriteCallbackOutput (output, childUpdatePanelIDs, null,
FormatListIDs (_childUpdatePanels, false));
WriteCallbackOutput (output, panelsToRefreshIDs, null,
FormatListIDs (_panelsToRefresh, false));
WriteCallbackOutput (output, asyncPostBackTimeout,
null, AsyncPostBackTimeout.ToString ());
- WriteCallbackOutput (output, pageTitle, null,
Page.Title);
+ if (!IsMultiForm)
+ WriteCallbackOutput (output, pageTitle, null,
Page.Title);
if (_dataItems != null)
foreach (Control control in _dataItems.Keys) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches