0
此代碼我轉換爲每個需要的Javascript中的StringBuilder
http://jquerymsgbox.ibrahimkalyoncu.com/
大家好我寫了下面的代碼來顯示一個警告
public static string ShowAlertMessage(string pHeader, string pError, Page page)
{
//StringBuilder sb = new StringBuilder();
StringBuilder strScript = new StringBuilder();
strScript.Append("<script type='text/javascript' src='Scripts/jquery-1.4.1.js'>");
strScript.Append("</script>");
strScript.Append("<script type='text/javascript' src='Scripts/jquery.msgBox.js'>");
strScript.Append("</script>");
strScript.Append("<link href='Styles/msgBoxLight.css' rel='stylesheet' type='text/css'>");
strScript.Append("</link>");
strScript.Append("<script type='text/javascript'>");
strScript.Append("function example()");
strScript.Append("{");
strScript.Append("$msgBox({");
strScript.Append("title:" + pHeader + "");
strScript.Append(",");
strScript.AppendLine("content:" + pError + "");
strScript.Append("});");
strScript.Append("}");
strScript.Append("</script>");
page.ClientScript.RegisterStartupScript(page.GetType(), "Script", strScript.ToString(), true);
return strScript.ToString();
}
但是,這是不是給我的預期輸出可以幫助我一些我出錯的地方
這是生成的字符串生成器
<script type='text/javascript' src='Scripts/jquery-1.4.1.js'></script>
<script type='text/javascript' src='Scripts/jquery.msgBox.js'></script>
<link href='Styles/msgBoxLight.css' rel='stylesheet' type='text/css'></link>
<script type='text/javascript'>
function example()
{
$msgBox({title:Testing Code,
content:Hello
});
}
</script>
答案**什麼問題**?它給你什麼?什麼是預期的輸出? – SLaks
爲什麼'append'和'toString'以大寫字母開頭? –
提示:閱讀生成的Javascript,你會看到問題 – SLaks