encode ExpandoAttribute if need.
[mono.git] / mcs / class / System.Web.Extensions / System.Web.UI / ScriptManager.cs
index 6d687830b917f65fe9fde85c15ae2b4e094c0bfa..14e87dfd08621dddb3ffe5cea27dbd0d5308ccb3 100644 (file)
@@ -1259,8 +1259,17 @@ namespace System.Web.UI
                        if (_expandoAttributes != null) {
                                for (int i = 0; i < _expandoAttributes.Count; i++) {
                                        RegisteredExpandoAttribute attr = _expandoAttributes [i];
-                                       if (HasBeenRendered (attr.Control))
-                                               WriteCallbackOutput (writer, expando, "document.getElementById('Label2')['" + attr.Name + "']", "\"" + attr.Value + "\"");
+                                       if (HasBeenRendered (attr.Control)) {
+                                               string value;
+                                               if (attr.Encode) {
+                                                       StringWriter sw = new StringWriter ();
+                                                       Newtonsoft.Json.JavaScriptUtils.WriteEscapedJavaScriptString (attr.Value, sw);
+                                                       value = sw.ToString ();
+                                               }
+                                               else
+                                                       value = "\"" + attr.Value + "\"";
+                                               WriteCallbackOutput (writer, expando, "document.getElementById('Label2')['" + attr.Name + "']", value);
+                                       }
                                }
                        }
                }