stringBuilder抛出无效参数

时间:2015-09-30 12:33:04

标签: c# string stringbuilder

任何人都可以告诉我为什么ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType, key, script.ToString, true);返回最佳重载方法...有无效参数...我相信脚本是问题

 StringBuilder script = new StringBuilder();
            string key = "setTableName";
            if (Page.ClientScript.IsClientScriptBlockRegistered(Page.GetType(), key) == false)
            {
                script.Append("\ng_tableName ='");
                script.Append(tableName + "';");

                script.Append("\ng_layerName ='");
                script.Append(layerName + "';");
            }
            ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType, key, script.ToString, true);

1 个答案:

答案 0 :(得分:1)

正如FrédéricHamidi所说,只需用script.ToString替换script.ToString()来调用函数而不是将其作为参数传递:

ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), key, script.ToString(), true);