I want to write a action method returning Javascript. How to run javascript using MVC controller?
I tried the following, but it fails to work properly. It shows file download - security warning?
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult About(clsABC param)
{
string message = "Hello! World.";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload=function(){");
sb.Append("alert('");
sb.Append(message);
sb.Append("')};");
sb.Append("</script>");
return JavaScript(sb.ToString());
}
Any solution to this problem?
Thanks, Kapil