0

必要に応じて変換したこのコード

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>
4

1 に答える 1

0

これで答えが出ました

public static string ShowAlertMessage(string pHeader, string pError)
{
StringBuilder strScript = new StringBuilder();
strScript.Append("<script type=\"text/javascript\" src=\"").Append("Scripts/jquery-1.4.1.js").Append("\"></script>");
strScript.Append("<script type=\"text/javascript\" src=\"").Append("Scripts/jquery.msgBox.js").Append("\"></script>");
strScript.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"").Append("Styles/msgBoxLight.css").Append("\" />");
strScript.Append("<script type=\"text/javascript\">");
strScript.Append("(function example()");
strScript.Append("{");
strScript.Append("$.msgBox({");
strScript.Append("title:'" + pHeader + "'");
strScript.Append(",");
strScript.Append("content:'" + pError + "'");
strScript.Append("});");
strScript.Append("})();");
strScript.Append("</script>");
return strScript.ToString();
}
于 2013-06-02T17:19:47.920 に答える