I have this code:
@if (!string.IsNullOrWhiteSpace (Model.ErrorMessage))
{
<Script>
$ ("#ModalError').modal.('show.');
</Script>
Response.Write("<script>alert('Olá');</script>");
HttpContext.Current.Response.Write("<script>alert('Olá');</script>");
}
Where I check if Model.Error message is different from empty, so I wanted to give an alert to the user displaying the error message, but none of the way it is in the middle of this condition is working.
I've tried it too:
@if (!String.IsNullOrEmpty(ViewData["erro"] as string))
{
<script>alert(@ViewData["erro"]);</script>
}
This is a part of the view.
My controller looks like this:
public ActionResult Login(LoginViewModel model, SignInMessage message)
{
if (!String.IsNullOrEmpty(model.ErrorMessage))
ViewData["erro"] = !String.IsNullOrEmpty(model.ErrorMessage) ? model.ErrorMessage : null;
return this.View(model);
}
Does anyone know how to solve it?