Dorababu Meka

Dorababu Meka

  • 227
  • 8.3k
  • 1.7m

Javascript as Dynamic class

Jun 3 2013 2:12 AM
Hi all I have created a javascript function along with the scripts in a class file using string builder as follows
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();
}
This method I am calling on each and every page on the button click where ever I required as follows

ClientScript.RegisterStartupScript(this.GetType(), "Popup", Alert.ShowAlertMessage("Hello", "Welcome"), true);

But this is not giving me the output I needed, the one which I converted is the following
http://jquerymsgbox.ibrahimkalyoncu.com/

can some one help me please to achieve my requirement

Answers (7)