A quick solution can be to return the
JsonResult
back to the client side with a flag to and put condition to either alert error message or continue normally, which would be like:
public ActionResult SaveDetailedInfo(Option[] Options)
{
ActionResult actionResult = null;
if (Email !="")
{
actionResult = Json(new
{
status = "Success",
message = PartialView("../Application/ContactEmailbox");
});
}
else
{
actionResult = Json(new
{
status = "Error",
message = "Your Error Message here to show as alert"
});
}
return actionResult;
}
Now in the ajax call success, you can check if it was
success or
error:
success: function (data) {
if (data.status == "Success") {
$('#dialog').html(data.message);
$('#dialog').dialog('open');
$(".ui-dialog-titlebar-close").hide();
} else {
alert(data.message);
}
}
Hope it helps!