i'm new here in stackoverflow and also new to asp.net i would like to ask how to show message box in mvc asp.net. This is my code, but it will return NullReferenceException. Thanks for your help.`
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult myfunction(MyViewModels myModel)
{
System.Web.UI.ScriptManager script_manager = new System.Web.UI.ScriptManager();
if (ModelState.IsValid) {
createRequest(myModel);
script_manager.Page.ClientScript.RegisterStartupScript(this.GetType(), "showMyMessage", "ShowMessage('Requested Successfully.');", true);
return RedirectToAction("GeneratePDF", "Forms", myModel);
}
else
{
script_manager.Page.ClientScript.RegisterStartupScript(this.GetType(), "showMyMessage", "ShowMessage('Requested failed.');", true);
return RedirectToAction("Index");
}
}`