static string EncryptAssemblyResource (string asmName, string resName)
{
byte[] key = GetEncryptionKey ();
- byte[] bytes = Encoding.UTF8.GetBytes (String.Format ("{0};{1}", asmName, resName));
+ byte[] bytes = Encoding.UTF8.GetBytes (String.Concat (asmName, ";", resName));
string result;
ICryptoTransform encryptor = TripleDES.Create ().CreateEncryptor (key, init_vector);
result = GetHexString (encryptor.TransformFinalBlock (bytes, 0, bytes.Length));
bytes = null;
- return String.Format ("d={0}", result.ToLower (CultureInfo.InvariantCulture));
+ return String.Concat ("d=", result.ToLower (CultureInfo.InvariantCulture));
}
static void DecryptAssemblyResource (string val, out string asmName, out string resName)
string atime = String.Empty;
string extra = String.Empty;
#if SYSTEM_WEB_EXTENSIONS
- extra = String.Format ("{0}n={1}", QueryParamSeparator, notifyScriptLoaded ? "t" : "f");
+ extra = String.Concat (QueryParamSeparator, "n=", notifyScriptLoaded ? "t" : "f");
#endif
#if TARGET_JVM
atime = String.Format ("{0}t={1}", QueryParamSeparator, assembly.GetHashCode ());
#else
if (apath != String.Empty)
- atime = String.Format ("{0}t={1}", QueryParamSeparator, File.GetLastWriteTimeUtc (apath).Ticks);
+ atime = String.Concat (QueryParamSeparator, "t=", File.GetLastWriteTimeUtc (apath).Ticks);
#endif
- string href = String.Format ("{0}?{1}{2}{3}", HandlerFileName,
- EncryptAssemblyResource (aname, resourceName), atime, extra);
+ string href = HandlerFileName + "?" + EncryptAssemblyResource (aname, resourceName) + atime + extra;
HttpContext ctx = HttpContext.Current;
if (ctx != null && ctx.Request != null) {
}
#endif
if (wra == null)
- throw new HttpException (404, string.Format ("Resource {0} not found", resourceName));
+ throw new HttpException (404, String.Concat ("Resource ", resourceName, " not found"));
context.Response.ContentType = wra.ContentType;
Stream s = assembly.GetManifestResourceStream (resourceName);
if (s == null)
- throw new HttpException (404, string.Format ("Resource {0} not found", resourceName));
+ throw new HttpException (404, String.Concat ("Resource ", resourceName, " not found"));
if (wra.PerformSubstitution) {
StreamReader r = new StreamReader (s);
+2007-12-13 Marek Habersack <mhabersack@novell.com>
+
+ * AssemblyResourceLoader.cs: speed optimization - use String.Concat
+ instead of String.Format in some cases.
+
2007-11-12 Igor Zelmanovich <igorz@mainsoft.com>
* AssemblyResourceLoader.cs:
string dynamic_dir = null;
string user = Environment.UserName;
int tempDirTag = 0;
+ string dirPrefix = String.Concat (user, "-temp-aspnet-");
for (int i = 0; ; i++){
- string d = Path.Combine (Path.GetTempPath (),
- String.Format ("{0}-temp-aspnet-{1:x}", user, i));
+ string d = Path.Combine (Path.GetTempPath (), String.Concat (dirPrefix, i.ToString ("x")));
try {
CreateDirectory (d);
throw new ArgumentException ("Cannot be null or empty", "physicalPath");
// 'type' is not checked. If it's null, we'll throw a NullReferenceException
- if (!typeof (IRegisteredObject).IsAssignableFrom (type)) {
- string msg = String.Format ("Type '{0}' does not implement IRegisteredObject.", type.Name);
- throw new ArgumentException (msg, "type");
- }
+ if (!typeof (IRegisteredObject).IsAssignableFrom (type))
+ throw new ArgumentException (String.Concat ("Type '", type.Name, "' does not implement IRegisteredObject."), "type");
//
// ArgumentException is thrown for the physical path from the internal object created
if (ireg == null)
return null;
- if (failIfExists) {
- string msg = String.Format ("Well known object of type '{0}' already " +
- "exists in this domain.", type.Name);
- throw new InvalidOperationException (msg);
- }
+ if (failIfExists)
+ throw new InvalidOperationException (String.Concat ("Well known object of type '", type.Name, "' already exists in this domain."));
return ireg;
}
+2007-12-13 Marek Habersack <mhabersack@novell.com>
+
+ * ApplicationManager.cs, ApplicationHost.cs,
+ DefaultVirtualPathProvider.cs: speed optimization - use
+ String.Concat instead of String.Format in some cases.
+
2007-11-03 Gert Driesen <drieseng@users.sourceforge.net>
* ApplicationHost.cs: On 2.0, also make PrivateBinPath an absolute
if (virtualDir == null || virtualDir == "")
throw new ArgumentNullException ("virtualDir");
- if (UrlUtils.IsRelativeUrl (virtualDir)) {
- string msg = String.Format ("The relative virtual path '{0}', is not allowed here.", virtualDir);
- throw new ArgumentException (msg);
- }
+ if (UrlUtils.IsRelativeUrl (virtualDir))
+ throw new ArgumentException (String.Concat ("The relative virtual path '", virtualDir, "', is not allowed here."));
string phys_path = HostingEnvironment.MapPath (virtualDir);
return Directory.Exists (phys_path);
if (virtualPath == null || virtualPath == "")
throw new ArgumentNullException ("virtualPath");
- if (UrlUtils.IsRelativeUrl (virtualPath)) {
- string msg = String.Format ("The relative virtual path '{0}', is not allowed here.", virtualPath);
- throw new ArgumentException (msg);
- }
+ if (UrlUtils.IsRelativeUrl (virtualPath))
+ throw new ArgumentException (String.Concat ("The relative virtual path '", virtualPath, "', is not allowed here."));
string phys_path = HostingEnvironment.MapPath (virtualPath);
return File.Exists (phys_path);
if (virtualDir == null || virtualDir == "")
throw new ArgumentNullException ("virtualDir");
- if (UrlUtils.IsRelativeUrl (virtualDir)) {
- string msg = String.Format ("The relative virtual path '{0}', is not allowed here.", virtualDir);
- throw new ArgumentException (msg);
- }
+ if (UrlUtils.IsRelativeUrl (virtualDir))
+ throw new ArgumentException (String.Concat ("The relative virtual path '", virtualDir, "', is not allowed here."));
return new DefaultVirtualDirectory (virtualDir);
}
if (virtualPath == null || virtualPath == "")
throw new ArgumentNullException ("virtualPath");
- if (UrlUtils.IsRelativeUrl (virtualPath)) {
- string msg = String.Format ("The relative virtual path '{0}', is not allowed here.", virtualPath);
- throw new ArgumentException (msg);
- }
+ if (UrlUtils.IsRelativeUrl (virtualPath))
+ throw new ArgumentException (String.Concat ("The relative virtual path '", virtualPath, "', is not allowed here."));
return new DefaultVirtualFile (virtualPath);
}
+2007-12-13 Marek Habersack <mhabersack@novell.com>
+
+ * SqlProfileProvider.cs, ProfileParser.cs: speed optimization -
+ use String.Concat instead of String.Format in some cases.
+
2007-12-12 Vladimir Krasnov <vladimirk@mainsoft.com>
* ProfileParser.jvm.cs: Profile types loading optimized
{
string typeName;
if (AppCodeCompiler.DefaultAppCodeAssemblyName != null)
- typeName = String.Format ("ProfileCommon, {0}", AppCodeCompiler.DefaultAppCodeAssemblyName);
+ typeName = String.Concat ("ProfileCommon, ", AppCodeCompiler.DefaultAppCodeAssemblyName);
else
typeName = "ProfileCommon";
{
string typeName;
if (AppCodeCompiler.DefaultAppCodeAssemblyName != null)
- typeName = String.Format ("ProfileCommon{0}, {1}",
- groupName,
- AppCodeCompiler.DefaultAppCodeAssemblyName);
+ typeName = String.Concat ("ProfileCommon", groupName, ", ", AppCodeCompiler.DefaultAppCodeAssemblyName);
else
- typeName = String.Format ("ProfileCommon{0}", groupName);
+ typeName = String.Concat ("ProfileCommon", groupName);
Type profileGroupType = Type.GetType (typeName);
if (profileGroupType == null) {
if (p == null)
throw new ArgumentNullException (pName);
if (p.Length == 0 || p.Length > length || p.IndexOf (",") != -1)
- throw new ArgumentException (String.Format ("invalid format for {0}", pName));
+ throw new ArgumentException (String.Concat ("invalid format for ", pName));
}
static int GetReturnValue (DbParameter returnValue)
+2007-12-13 Marek Habersack <mhabersack@novell.com>
+
+ * SessionId.cs: speed optimization - use String.Concat instead of
+ String.Format in some cases.
+
2007-11-23 Marek Habersack <mhabersack@novell.com>
* SessionSQLServerHandler.cs: Remove a memory leak and improve
if (key == null)
throw new ArgumentNullException ("key");
if (key.Length != half_len)
- throw new ArgumentException (String.Format ("key must be {0} bytes long.", half_len));
+ throw new ArgumentException (String.Concat ("key must be ", half_len.ToString (), " bytes long."));
// Just a standard hex conversion
char[] res = new char [IdLength];
+2007-12-13 Marek Habersack <mhabersack@novell.com>
+
+ * HtmlForm.cs, HtmlButton.cs: speed optimization - use String.Concat
+ instead of String.Format in some cases.
+
2007-11-07 Juraj Skripsky <js@hotfeet.ch>
* HtmlForm.cs (RenderAttributes): Render ClientID of DefaultButton.
if (CausesValidation && Page != null && Page.AreValidatorsUplevel ()) {
if (postback)
writer.WriteAttribute ("onclick",
- String.Format ("javascript:{{if (typeof(Page_ClientValidate) != 'function' || Page_ClientValidate()) {0}}}",
- csm.GetPostBackEventReference (this, String.Empty)));
+ String.Concat ("javascript:{if (typeof(Page_ClientValidate) != 'function' || Page_ClientValidate()) ",
+ csm.GetPostBackEventReference (this, String.Empty), "}"));
else
writer.WriteAttribute ("onclick",
"if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate();");
ID));
if (DetermineRenderUplevel ()) {
+ string formReference = Page.IsMultiForm ? Page.theForm + "." : String.Empty;
+
w.WriteAttribute (
"onkeypress",
- String.Format ("javascript:return {1}WebForm_FireDefaultButton(event, '{0}')",
- c.ClientID, Page.IsMultiForm ? Page.theForm + "." : null));
+ "javascript:return " + formReference + "WebForm_FireDefaultButton(event, '" + c.ClientID + "')");
}
}
#endif
public override string ConnectionString {
get {
if (connectionString == null) {
- connectionString = String.Format ("Provider={0}; Data Source={1}",
- PROVIDER_STRING, GetPhysicalDataFilePath ());
+ connectionString = String.Concat ("Provider=", PROVIDER_STRING, "; Data Source=", GetPhysicalDataFilePath ());
}
return connectionString;
protected virtual void RegisterValidatorDeclaration ()
{
Page.ClientScript.RegisterArrayDeclaration ("Page_Validators",
- String.Format ("document.getElementById ('{0}')", ClientID));
+ String.Concat ("document.getElementById ('", ClientID, "')"));
}
#if NET_2_0
+2007-12-13 Marek Habersack <mhabersack@novell.com>
+
+ * Menu.cs, TreeView.cs: optimize use of String.Format in
+ OnPreRender.
+ Speed optimization - use String.Concat instead of String.Format in
+ some cases.
+
+ * GridView.cs, DetailsView.cs: optimize use of String.Format in
+ OnPreRender.
+
+ * CheckBox.cs, AccessDataSource.cs, WebColorConverter.cs,
+ WebControl.cs,TextBox.cs, DropDownList.cs, ValidationSummary.cs,
+ ListBox.cs, Panel.cs, BaseValidator.cs, LinkButton.cs: speed
+ optimization - use String.Concat instead of String.Format in some cases.
+
2007-12-13 Vladimir Krasnov <vladimirk@mainsoft.com>
* Menu.cs: fixed rendering without head tag on page
if (AutoPostBack) {
#if NET_2_0
string onclick = Page.ClientScript.GetPostBackEventReference (GetPostBackOptions (), true);
- onclick = String.Format ("setTimeout('{0}', 0)", onclick.Replace ("\\", "\\\\").Replace ("'", "\\'"));
+ onclick = String.Concat ("setTimeout('", onclick.Replace ("\\", "\\\\").Replace ("'", "\\'"), "', 0)");
w.AddAttribute (HtmlTextWriterAttribute.Onclick, BuildScriptAttribute ("onclick", onclick));
#else
w.AddAttribute (HtmlTextWriterAttribute.Onclick,
PageIndex = page;\r
}\r
}\r
- \r
+\r
+ const string onPreRenderScript = @"var {0} = new Object ();\r
+{0}.pageIndex = {1};\r
+{0}.uid = {2};\r
+{0}.form = {3};\r
+";\r
+\r
protected internal override void OnPreRender (EventArgs e)\r
{\r
base.OnPreRender (e);\r
- \r
+\r
if (EnablePagingCallbacks)\r
{\r
if (!Page.ClientScript.IsClientScriptIncludeRegistered (typeof(DetailsView), "DetailsView.js")) {\r
Page.ClientScript.RegisterHiddenField (ClientID + "_Page", PageIndex.ToString ());\r
\r
string cgrid = ClientID + "_data";\r
- string script = string.Format ("var {0} = new Object ();\n", cgrid);\r
- script += string.Format ("{0}.pageIndex = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral (PageIndex));\r
- script += string.Format ("{0}.uid = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral (UniqueID));\r
- script += string.Format ("{0}.form = {1};\n", cgrid, Page.theForm);\r
+ string script = String.Format (onPreRenderScript,\r
+ cgrid,\r
+ ClientScriptManager.GetScriptLiteral (PageIndex),\r
+ ClientScriptManager.GetScriptLiteral (UniqueID),\r
+ Page.theForm);\r
+ \r
Page.ClientScript.RegisterStartupScript (typeof(TreeView), this.UniqueID, script, true);\r
\r
// Make sure the basic script infrastructure is rendered\r
if (AutoPostBack) {
#if NET_2_0
string onchange = Page.ClientScript.GetPostBackEventReference (GetPostBackOptions (), true);
- onchange = String.Format ("setTimeout('{0}', 0)", onchange.Replace ("\\", "\\\\").Replace ("'", "\\'"));
+ onchange = String.Concat ("setTimeout('", onchange.Replace ("\\", "\\\\").Replace ("'", "\\'"), "', 0)");
writer.AddAttribute (HtmlTextWriterAttribute.Onchange, BuildScriptAttribute ("onchange", onchange));
#else
writer.AddAttribute (HtmlTextWriterAttribute.Onchange,
SortExpression = Page.Request.Form [ClientID + "_SortExpression"];
}
}
-
+
+
+ const string onPreRenderScript = @"var {0} = new Object ();
+{0}.pageIndex = {1};
+{0}.sortExp = {2};
+{0}.sortDir = {3};
+{0}.uid = {4};
+{0}.form = {5};
+";
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
-
- if (EnableSortingAndPagingCallbacks)
- {
+
+ if (EnableSortingAndPagingCallbacks) {
if (!Page.ClientScript.IsClientScriptIncludeRegistered (typeof(GridView), "GridView.js")) {
string url = Page.ClientScript.GetWebResourceUrl (typeof(GridView), "GridView.js");
Page.ClientScript.RegisterClientScriptInclude (typeof(GridView), "GridView.js", url);
}
string cgrid = ClientID + "_data";
- string script = string.Format ("var {0} = new Object ();\n", cgrid);
- script += string.Format ("{0}.pageIndex = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral (PageIndex));
- script += string.Format ("{0}.sortExp = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral (SortExpression == null ? "" : SortExpression));
- script += string.Format ("{0}.sortDir = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral ((int) SortDirection));
- script += string.Format ("{0}.uid = {1};\n", cgrid, ClientScriptManager.GetScriptLiteral (UniqueID));
- script += string.Format ("{0}.form = {1};\n", cgrid, Page.theForm);
+ string script = String.Format (onPreRenderScript,
+ cgrid,
+ ClientScriptManager.GetScriptLiteral (PageIndex),
+ ClientScriptManager.GetScriptLiteral (SortExpression == null ? "" : SortExpression),
+ ClientScriptManager.GetScriptLiteral ((int) SortDirection),
+ ClientScriptManager.GetScriptLiteral (UniqueID),
+ Page.theForm);
+
Page.ClientScript.RegisterStartupScript (typeof(TreeView), this.UniqueID, script, true);
// Make sure the basic script infrastructure is rendered
Page.ClientScript.GetPostBackClientHyperlink (this, "");
}
}
-
+
protected internal override void Render (HtmlTextWriter writer)
{
PrepareControlHierarchy ();
if (CausesValidation && Page.AreValidatorsUplevel ()) {
ClientScriptManager csm = new ClientScriptManager (Page);
w.AddAttribute (HtmlTextWriterAttribute.Href,
- String.Format ("javascript:{{if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); {0};}}",
- csm.GetPostBackEventReference (this, String.Empty)));
+ String.Concat ("javascript:{if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); ",
+ csm.GetPostBackEventReference (this, String.Empty), ";}"));
} else {
w.AddAttribute (HtmlTextWriterAttribute.Href, Page.ClientScript.GetPostBackClientHyperlink (this, ""));
}
if (AutoPostBack) {
#if NET_2_0
string onchange = Page.ClientScript.GetPostBackEventReference (GetPostBackOptions (), true);
- onchange = String.Format ("setTimeout('{0}', 0)", onchange.Replace ("\\", "\\\\").Replace ("'", "\\'"));
+ onchange = String.Concat ("setTimeout('", onchange.Replace ("\\", "\\\\").Replace ("'", "\\'"), "', 0)");
writer.AddAttribute (HtmlTextWriterAttribute.Onchange, BuildScriptAttribute ("onchange", onchange));
#else
writer.AddAttribute (HtmlTextWriterAttribute.Onchange,
EnsureChildControls ();
base.OnDataBinding (e);
}
+
+ const string onPreRenderScript = "var {0} = new Object ();\n{0}.webForm = {1};\n{0}.disappearAfter = {2};\n{0}.vertical = {3};";
protected internal override void OnPreRender (EventArgs e)
{
}
string cmenu = ClientID + "_data";
- string script = string.Concat ("var ", cmenu, " = new Object ();\n");
- script += string.Format ("{0}.webForm = {1};\n", cmenu, Page.IsMultiForm ? Page.theForm : "window");
- script += string.Format ("{0}.disappearAfter = {1};\n", cmenu, ClientScriptManager.GetScriptLiteral (DisappearAfter));
- script += string.Format ("{0}.vertical = {1};\n", cmenu, ClientScriptManager.GetScriptLiteral (Orientation == Orientation.Vertical));
+ string script = String.Format (onPreRenderScript,
+ cmenu,
+ Page.IsMultiForm ? Page.theForm : "window",
+ ClientScriptManager.GetScriptLiteral (DisappearAfter),
+ ClientScriptManager.GetScriptLiteral (Orientation == Orientation.Vertical));
+
if (DynamicHorizontalOffset != 0)
- script += string.Format ("{0}.dho = {1};\n", cmenu, ClientScriptManager.GetScriptLiteral (DynamicHorizontalOffset));
+ script += String.Concat (cmenu, ".dho = ", ClientScriptManager.GetScriptLiteral (DynamicHorizontalOffset), ";\n");
if (DynamicVerticalOffset != 0)
- script += string.Format ("{0}.dvo = {1};\n", cmenu, ClientScriptManager.GetScriptLiteral (DynamicVerticalOffset));
+ script += String.Concat (cmenu, ".dvo = ", ClientScriptManager.GetScriptLiteral (DynamicVerticalOffset), ";\n");
// The order in which styles are defined matters when more than one class
// is assigned to an element
return (item.Depth + 1 < StaticDisplayLevels + MaximumDynamicDisplayLevels) && item.ChildItems.Count > 0;
}
+ static string MakeHandlerJavaScript (string handlerName, string param1, string param2, string param3)
+ {
+ return "javascript:Menu_" + handlerName + "('" + param1 + "','" + param2 + "'," + param3 + ")";
+ }
+
void RenderMenuItem (HtmlTextWriter writer, MenuItem item, bool notLast, bool isFirst) {
bool displayChildren = DisplayChildren (item);
bool dynamicChildren = displayChildren && (item.Depth + 1 >= StaticDisplayLevels);
string parentId = isDynamicItem ? "'" + item.Parent.Path + "'" : "null";
if (dynamicChildren) {
- writer.AddAttribute ("onmouseover", string.Format ("javascript:Menu_OverItem ('{0}','{1}',{2})", ClientID, item.Path, parentId));
- writer.AddAttribute ("onmouseout", string.Format ("javascript:Menu_OutItem ('{0}','{1}')", ClientID, item.Path));
- }
- else if (isDynamicItem) {
- writer.AddAttribute ("onmouseover", string.Format ("javascript:Menu_OverDynamicLeafItem ('{0}','{1}',{2})", ClientID, item.Path, parentId));
- writer.AddAttribute ("onmouseout", string.Format ("javascript:Menu_OutItem ('{0}','{1}',{2})", ClientID, item.Path, parentId));
- }
- else {
- writer.AddAttribute ("onmouseover", string.Format ("javascript:Menu_OverStaticLeafItem ('{0}','{1}')", ClientID, item.Path));
- writer.AddAttribute ("onmouseout", string.Format ("javascript:Menu_OutItem ('{0}','{1}')", ClientID, item.Path));
+ writer.AddAttribute ("onmouseover",
+ "javascript:Menu_OverItem ('" + ClientID + "','" + item.Path + "'," + parentId + ")");
+ writer.AddAttribute ("onmouseout",
+ "javascript:Menu_OutItem ('" + ClientID + "','" + item.Path + "')");
+ } else if (isDynamicItem) {
+ writer.AddAttribute ("onmouseover",
+ "javascript:Menu_OverDynamicLeafItem ('" + ClientID + "','" + item.Path + "'," + parentId + ")");
+ writer.AddAttribute ("onmouseout",
+ "javascript:Menu_OutItem ('" + ClientID + "','" + item.Path + "'," + parentId + ")");
+ } else {
+ writer.AddAttribute ("onmouseover",
+ "javascript:Menu_OverStaticLeafItem ('" + ClientID + "','" + item.Path + "')");
+ writer.AddAttribute ("onmouseout",
+ "javascript:Menu_OutItem ('" + ClientID + "','" + item.Path + "')");
}
writer.RenderBeginTag (HtmlTextWriterTag.Td);
}
if (isDynamicItem && DynamicItemFormatString.Length > 0) {
- writer.Write (string.Format (DynamicItemFormatString, item.Text));
+ writer.Write (String.Format (DynamicItemFormatString, item.Text));
}
else if (!isDynamicItem && StaticItemFormatString.Length > 0) {
- writer.Write (string.Format (StaticItemFormatString, item.Text));
+ writer.Write (String.Format (StaticItemFormatString, item.Text));
}
else {
writer.Write (item.Text);
if (image != "") {
image = ResolveClientUrl (image);
#if !NET_2_0 // see HtmlTextWriter.WriteStyleAttribute(string, string, bool)
- image = String.Format ("url({0})", image);
+ image = String.Concat ("url(", image, ")");
#endif
w.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, image);
}
throw new InvalidOperationException (String.Format ("The DefaultButton of '{0}' must be the ID of a control of type IButtonControl.", ID));
Page.ClientScript.RegisterWebFormClientScript ();
- w.AddAttribute ("onkeypress", String.Format ("javascript:return {1}WebForm_FireDefaultButton(event, '{0}')", button.ClientID, Page.IsMultiForm ? Page.theForm + "." : null));
+
+ string formReference = Page.IsMultiForm ? Page.theForm + "." : String.Empty;
+ w.AddAttribute ("onkeypress",
+ "javascript:return " + formReference + "WebForm_FireDefaultButton(event, '" + button.ClientID + "')");
}
if (Direction != ContentDirection.NotSet) {
w.AddAttribute ("onkeypress", "if (WebForm_TextBoxKeyHandler(event) == false) return false;", false);
string onchange = Page.ClientScript.GetPostBackEventReference (GetPostBackOptions (), true);
- onchange = String.Format ("setTimeout('{0}', 0)", onchange.Replace ("\\", "\\\\").Replace ("'", "\\'"));
+ onchange = String.Concat ("setTimeout('", onchange.Replace ("\\", "\\\\").Replace ("'", "\\'"), "', 0)");
w.AddAttribute (HtmlTextWriterAttribute.Onchange, BuildScriptAttribute ("onchange", onchange));
}
#else
}
return res;
}
+
+ const string onPreRenderScript_1 = @"var {0} = new Object ();\n{0}.treeId = {1};\n{0}.uid = {2};\n{0}.showImage = {3};\n";
+ const string onPreRenderScript_2 = @"{0}.form = {1};\n{0}.PopulateNode = function(nodeId) {{ {2}; }};\n{0}.populateFromClient = {3};\n{0}.expandAlt = {4};\n{0}.collapseAlt = {5};\n";
protected internal override void OnPreRender (EventArgs e)
{
}
string ctree = ClientID + "_data";
- string script = string.Format ("var {0} = new Object ();\n", ctree);
- script += string.Format ("{0}.treeId = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (ClientID));
- script += string.Format ("{0}.uid = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (UniqueID));
- script += string.Format ("{0}.showImage = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (ShowExpandCollapse));
+ string script = String.Format (onPreRenderScript_1,
+ ctree,
+ ClientScriptManager.GetScriptLiteral (ClientID),
+ ClientScriptManager.GetScriptLiteral (UniqueID),
+ ClientScriptManager.GetScriptLiteral (ShowExpandCollapse));
if (ShowExpandCollapse) {
bool defaultImages = ShowLines || ImageSet != TreeViewImageSet.Custom || (ExpandImageUrl == "" && CollapseImageUrl == "");
- script += string.Format ("{0}.defaultImages = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (defaultImages));
+ script += String.Concat (ctree, ".defaultImages = ", ClientScriptManager.GetScriptLiteral (defaultImages), ";\n");
ImageStyle imageStyle = GetImageStyle ();
if (!defaultImages) {
- script += string.Format ("{0}.expandImage = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (GetNodeImageUrl ("plus", imageStyle)));
- script += string.Format ("{0}.collapseImage = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (GetNodeImageUrl ("minus", imageStyle)));
+ script += String.Concat (ctree,
+ ".expandImage = ",
+ ClientScriptManager.GetScriptLiteral (GetNodeImageUrl ("plus", imageStyle)),
+ ";\n");
+ script += String.Concat (ctree,
+ ".collapseImage = ",
+ ClientScriptManager.GetScriptLiteral (GetNodeImageUrl ("minus", imageStyle)),
+ ";\n");
}
if (PopulateNodesFromClient)
- script += string.Format ("{0}.noExpandImage = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (GetNodeImageUrl ("noexpand", imageStyle)));
+ script += String.Concat (ctree,
+ ".noExpandImage = ",
+ ClientScriptManager.GetScriptLiteral (GetNodeImageUrl ("noexpand", imageStyle)),
+ ";\n");
}
if (Page != null) {
- script += string.Format ("{0}.form = {1};\n", ctree, Page.theForm);
- script += string.Format ("{0}.PopulateNode = function(nodeId) {{ {1}; }};\n", ctree, Page.ClientScript.GetCallbackEventReference ("this.uid", "nodeId", "TreeView_PopulateCallback", "this.treeId + \" \" + nodeId", "TreeView_PopulateCallback", false));
- script += string.Format ("{0}.populateFromClient = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (PopulateNodesFromClient));
- script += string.Format ("{0}.expandAlt = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (GetNodeImageToolTip (true, null)));
- script += string.Format ("{0}.collapseAlt = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (GetNodeImageToolTip (false, null)));
+ script += String.Format (onPreRenderScript_2,
+ ctree,
+ Page.theForm,
+ Page.ClientScript.GetCallbackEventReference ("this.uid", "nodeId", "TreeView_PopulateCallback",
+ "this.treeId + \" \" + nodeId",
+ "TreeView_PopulateCallback", false),
+ ClientScriptManager.GetScriptLiteral (PopulateNodesFromClient),
+ ClientScriptManager.GetScriptLiteral (GetNodeImageToolTip (true, null)),
+ ClientScriptManager.GetScriptLiteral (GetNodeImageToolTip (false, null)));
if (!Page.IsPostBack) {
SetNodesExpandedToDepthRecursive (Nodes);
if (Page.Header == null)
throw new InvalidOperationException ("Using TreeView.HoverNodeStyle requires Page.Header to be non-null (e.g. <head runat=\"server\" />).");
RegisterStyle (HoverNodeStyle, HoverNodeLinkStyle);
- script += string.Format ("{0}.hoverClass = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (HoverNodeStyle.RegisteredCssClass));
- script += string.Format ("{0}.hoverLinkClass = {1};\n", ctree, ClientScriptManager.GetScriptLiteral (HoverNodeLinkStyle.RegisteredCssClass));
+ script += String.Concat (ctree, ".hoverClass = ",
+ ClientScriptManager.GetScriptLiteral (HoverNodeStyle.RegisteredCssClass),
+ ";\n");
+ script += String.Concat (ctree, ".hoverLinkClass = ",
+ ClientScriptManager.GetScriptLiteral (HoverNodeLinkStyle.RegisteredCssClass),
+ ";\n");
}
Page.ClientScript.RegisterStartupScript (typeof(TreeView), this.UniqueID, script, true);
if (EnableClientScript && pre_render_called && Page.AreValidatorsUplevel ()) {
#endif
Page.ClientScript.RegisterArrayDeclaration ("Page_ValidationSummaries",
- String.Format ("document.getElementById ('{0}')", ClientID));
+ String.Concat ("document.getElementById ('", ClientID, "')"));
}
if ((ShowSummary && has_errors) || (EnableClientScript && pre_render_called))
if (s != "0")
return s;
- return String.Format (culture, "#{0:X2}{1:X2}{2:X2}", c.R, c.G, c.B);
+ return String.Concat ("#", c.R.ToString ("X2"), c.G.ToString ("X2"), c.B.ToString ("X2"));
}
}
}
if (attr [attr.Length - 1] == ';')
attr = attr.TrimEnd (_script_trim_chars);
- attr = String.Format ("{0};{1}", attr, tail);
+ attr = String.Concat (attr, ";", tail);
attrs.Remove (name);
return attr;
+2007-12-13 Marek Habersack <mhabersack@novell.com>
+
+ * ClientScriptManager.cs, MasterPageParser.cs, Control.cs,
+ Page.cs: speed optimization - use String.Concat instead of
+ String.Format in some cases.
+
2007-12-13 Igor Zelmanovich <igorz@mainsoft.com>
* Page.cs:
throw new ArgumentNullException ("control");
page.RequiresPostBackScript ();
- if(page.IsMultiForm)
- return String.Format ("{0}.__doPostBack('{1}','{2}')", page.theForm, control.UniqueID, argument);
- else
- return String.Format ("__doPostBack('{0}','{1}')", control.UniqueID, argument);
+ if(page.IsMultiForm)
+ return page.theForm + ".__doPostBack('" + control.UniqueID + "','" + argument + "')";
+ else
+ return "__doPostBack('" + control.UniqueID + "','" + argument + "')";
}
#if NET_2_0
}
#endif
- return String.Format ("{0}WebForm_DoPostback({1},{2},{3},{4},{5},{6},{7},{8})",
- prefix,
- ClientScriptManager.GetScriptLiteral (options.TargetControl.UniqueID),
- ClientScriptManager.GetScriptLiteral (options.Argument),
- ClientScriptManager.GetScriptLiteral (actionUrl),
- ClientScriptManager.GetScriptLiteral (options.AutoPostBack),
- ClientScriptManager.GetScriptLiteral (options.PerformValidation),
- ClientScriptManager.GetScriptLiteral (options.TrackFocus),
- ClientScriptManager.GetScriptLiteral (options.ClientSubmit),
- ClientScriptManager.GetScriptLiteral (options.ValidationGroup)
- );
+ return prefix + "WebForm_DoPostback(" +
+ ClientScriptManager.GetScriptLiteral (options.TargetControl.UniqueID) + "," +
+ ClientScriptManager.GetScriptLiteral (options.Argument) + "," +
+ ClientScriptManager.GetScriptLiteral (actionUrl) + "," +
+ ClientScriptManager.GetScriptLiteral (options.AutoPostBack) + "," +
+ ClientScriptManager.GetScriptLiteral (options.PerformValidation) + "," +
+ ClientScriptManager.GetScriptLiteral (options.TrackFocus) + "," +
+ ClientScriptManager.GetScriptLiteral (options.ClientSubmit) + "," +
+ ClientScriptManager.GetScriptLiteral (options.ValidationGroup) + ")";
}
internal void RegisterWebFormClientScript ()
public string GetCallbackEventReference (string target, string argument, string clientCallback, string context, string clientErrorCallback, bool useAsync)
{
RegisterWebFormClientScript ();
-
- return string.Format ("{6}WebForm_DoCallback({0},{1},{2},{3},{4},{5})", target, ((argument == null) ? "null" : argument), clientCallback, ((context == null) ? "null" : context), ((clientErrorCallback == null) ? "null" : clientErrorCallback), (useAsync ? "true" : "false"), (page.IsMultiForm ? page.theForm + "." : null));
+
+ string formReference = page.IsMultiForm ? page.theForm + "." : String.Empty;
+
+ return formReference + "WebForm_DoCallback(" +
+ target + "," +
+ ((argument == null) ? "null" : argument) + "," +
+ clientCallback + "," +
+ ((context == null) ? "null" : context) + "," +
+ ((clientErrorCallback == null) ? "null" : clientErrorCallback) + "," +
+ (useAsync ? "true" : "false") + ")";
}
#endif
defaultNameArray = new string [100];
for (int i = 0; i < 100; i++)
#if NET_2_0
- defaultNameArray [i] = String.Format ("ctl{0:D2}", i);
+ defaultNameArray [i] = String.Concat ("ctl", i.ToString ("D2"));
#else
defaultNameArray [i] = "_ctl" + i;
#endif
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("OnBubbleEvent {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("OnBubbleEvent ", _userId, " ", type_name));
}
#endif
return false;
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("OnDataBinding {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("OnDataBinding ", _userId, " ", type_name));
}
#endif
eh (this, e);
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("OnInit {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("OnInit ", _userId, " ", type_name));
}
#endif
eh (this, e);
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("OnLoad {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("OnLoad ", _userId, " ", type_name));
}
#endif
eh (this, e);
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("OnPreRender {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("OnPreRender ", _userId, " ", type_name));
}
#endif
eh (this, e);
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("OnUnload {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("OnUnload ", _userId, " ", type_name));
}
#endif
eh (this, e);
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("RaiseBubbleEvent {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("RaiseBubbleEvent ", _userId, " ", type_name));
}
#endif
if (c.OnBubbleEvent (source, args)) {
#if MONO_TRACE
if (trace != null)
- trace.Write ("control", String.Format ("End RaiseBubbleEvent (false) {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("End RaiseBubbleEvent (false) ", _userId, " ", type_name));
#endif
break;
}
#if MONO_TRACE
if (trace != null)
- trace.Write ("control", String.Format ("End RaiseBubbleEvent (true) {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("End RaiseBubbleEvent (true) ", _userId, " ", type_name));
#endif
c = c.Parent;
}
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("LoadRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("LoadRecursive ", _userId, " ", type_name));
}
#endif
#if NET_2_0
#if MONO_TRACE
if (trace != null)
- trace.Write ("control", String.Format ("End LoadRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("End LoadRecursive ", _userId, " ", type_name));
#endif
stateMask |= LOADED;
}
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("UnloadRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("UnloadRecursive ", _userId, " ", type_name));
}
#endif
if (HasControls ()) {
#if MONO_TRACE
if (trace != null)
- trace.Write ("control", String.Format ("End UnloadRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("End UnloadRecursive ", _userId, " ", type_name));
#endif
#if NET_2_0
if (Adapter != null)
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("PreRenderRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("PreRenderRecursive ", _userId, " ", type_name));
}
#endif
#if NET_2_0
}
#if MONO_TRACE
if (trace != null)
- trace.Write ("control", String.Format ("End PreRenderRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("End PreRenderRecursive ", _userId, " ", type_name));
#endif
}
#if NET_2_0
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("InitRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("InitRecursive ", _userId, " ", type_name));
}
#endif
SetNamingContainer (namingContainer);
OnInit (EventArgs.Empty);
#if MONO_TRACE
if (trace != null)
- trace.Write ("control", String.Format ("End InitRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("End InitRecursive ", _userId, " ", type_name));
#endif
TrackViewState ();
stateMask |= INITED;
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("SaveViewStateRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("SaveViewStateRecursive ", _userId, " ", type_name));
}
#endif
if (thisState == null && controlList == null && controlStates == null) {
#if MONO_TRACE
if (trace != null) {
- trace.Write ("control", String.Format ("End SaveViewStateRecursive {0} {1} saved nothing", _userId, type_name));
+ trace.Write ("control", "End SaveViewStateRecursive " + _userId + " " + type_name + " saved nothing");
trace.SaveViewState (this, null);
}
#endif
#if MONO_TRACE
if (trace != null) {
- trace.Write ("control", String.Format ("End SaveViewStateRecursive {0} {1} saved a Triplet", _userId, type_name));
+ trace.Write ("control", "End SaveViewStateRecursive " + _userId + " " + type_name + " saved a Triplet");
trace.SaveViewState (this, thisState);
}
#endif
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("LoadViewStateRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("LoadViewStateRecursive ", _userId, " ", type_name));
}
#endif
Triplet savedInfo = (Triplet) savedState;
#if MONO_TRACE
if (trace != null)
- trace.Write ("control", String.Format ("End LoadViewStateRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("End LoadViewStateRecursive ", _userId, " ", type_name));
#endif
stateMask |= VIEWSTATE_LOADED;
}
string type_name = null;
if (trace != null) {
type_name = GetType ().Name;
- trace.Write ("control", String.Format ("ApplyThemeRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("ApplyThemeRecursive ", _userId, " ", type_name));
}
#endif
if (Page.PageTheme != null && EnableTheming) {
#if MONO_TRACE
if (trace != null)
- trace.Write ("control", String.Format ("End ApplyThemeRecursive {0} {1}", _userId, type_name));
+ trace.Write ("control", String.Concat ("End ApplyThemeRecursive ", _userId, " ", type_name));
#endif
}
#endif
internal MasterPageParser (string virtualPath, string inputFile, HttpContext context)
: base (virtualPath, inputFile, context, "System.Web.UI.MasterPage")
{
- this.cacheEntryName = String.Format ("@@MasterPagePHIDS:{0}:{1}", virtualPath, inputFile);
+ this.cacheEntryName = String.Concat ("@@MasterPagePHIDS:", virtualPath, ":", inputFile);
contentPlaceHolderIds = HttpRuntime.InternalCache.Get (this.cacheEntryName) as List <string>;
}
ClientScript.RegisterWebFormClientScript ();
ClientScript.RegisterStartupScript (
"HtmlForm-DefaultButton-StartupScript",
- String.Format (
- "<script type=\"text/javascript\">\n{0}\nWebForm_AutoFocus('{1}');\n{2}\n</script>\n",
- ClientScriptManager.SCRIPT_BLOCK_START,
- _focusedControlID,
- ClientScriptManager.SCRIPT_BLOCK_END)
- );
+ "<script type=\"text/javascript\">\n" + ClientScriptManager.SCRIPT_BLOCK_START +
+ "\nWebForm_AutoFocus('" + _focusedControlID + "');\n" + ClientScriptManager.SCRIPT_BLOCK_END +
+ "\n</script>\n");
}
if (Form.SubmitDisabledControls && _hasEnabledControlArray) {
if (Form == null || !Page.Form.SubmitDisabledControls || !Page.Form.DetermineRenderUplevel ())
return;
_hasEnabledControlArray = true;
- Page.ClientScript.RegisterArrayDeclaration (EnabledControlArrayID, String.Format ("'{0}'", control.ClientID));
+ Page.ClientScript.RegisterArrayDeclaration (EnabledControlArrayID, String.Concat ("'", control.ClientID, "'"));
}
protected virtual void OnSaveStateComplete (EventArgs e)
try {
target.RaiseCallbackEvent (callbackArgument);
- }
- catch (Exception ex) {
- callbackEventError = String.Format ("e{0}", ex.Message);
+ } catch (Exception ex) {
+ callbackEventError = String.Concat ("e", ex.Message);
}
try {
callBackResult = target.GetCallbackResult ();
- }
- catch (Exception ex) {
- return String.Format ("e{0}", ex.Message);
+ } catch (Exception ex) {
+ return String.Concat ("e", ex.Message);
}
string eventValidation = ClientScript.GetEventValidationStateFormatted ();
- return String.Format ("{0}{1}|{2}{3}", callbackEventError, eventValidation == null ? 0 : eventValidation.Length, eventValidation, callBackResult);
+ return callbackEventError + (eventValidation == null ? "0" : eventValidation.Length.ToString ()) + "|" +
+ eventValidation + callBackResult;
}
[BrowsableAttribute (false)]