
1.when i click the save ,save successfull message has to be come like this green Colour message box
2.when i click save if some Error have Error message also dispaly like this Red Colour MEssage box
hi i want to display the Error message like this Please tell me if you know this i tried so many ways but i can show Error alert only please help me for this i have given my code also please help me
[HttpPost]
public ActionResult Index(MailModel objModelMail, HttpPostedFileBase fileUploader)
{
if (ModelState.IsValid)
{
Thread email = new Thread(delegate()
{
string from = "[email protected]"; //example:- [email protected]
using (MailMessage mail = new MailMessage(from, objModelMail.To))
{
mail.Subject = objModelMail.Subject;
mail.Body = objModelMail.Body;
if (fileUploader != null)
{
string fileName = Path.GetFileName(fileUploader.FileName);
mail.Attachments.Add(new Attachment(fileUploader.InputStream, fileName));
}
mail.IsBodyHtml = false;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential networkCredential = new NetworkCredential(from, "XXXXXXX");
smtp.UseDefaultCredentials = true;
smtp.Credentials = networkCredential;
smtp.Timeout = int.MaxValue;
smtp.Port = 587;
smtp.Send(mail);
ViewBag.Message = "Sent";
}
});
email.IsBackground = true;
email.Start();
ParsingTemplate();
return View("Index", objModelMail);//I need that successful message here itself
}
else
{
return View();//i need that Error Message here itself
}
}

Shakti Singh DulawatRank #668 · 3.6K reputationPosted May 5, 2016, 4:13 AM EDT
Munesh SharmaRank #174 · 13.9K reputationPosted May 5, 2016, 8:34 AM EDT
@foreach (var item in ViewData.ModelState) {
if (item.Value.Errors.Any()) {
foreach (ModelError e in item.Value.Errors) {
@e.ErrorMessage
}
}
}
mari muthuRank #8,962 · 213 reputationPosted May 5, 2016, 9:09 PM EDT
Shakti Singh DulawatRank #668 · 3.6K reputationPosted May 5, 2016, 9:45 PM EDT
Munesh SharmaRank #174 · 13.9K reputationPosted May 5, 2016, 9:46 PM EDT
mari muthuRank #8,962 · 213 reputationPosted May 5, 2016, 11:33 PM EDT
Bhuvanesh MohankumarRank #310 · 8.1K reputationPosted May 6, 2016, 12:03 AM EDT
Hi Marimuthu,
Are you using the Bootstrap in your MVC, if you are using BootStrap then its very simple.
Bhuvanesh MohankumarRank #310 · 8.1K reputationPosted May 6, 2016, 12:04 AM EDT
Boot strap alerts, sample code:
http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js">>
http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js">>
Alerts
Success! This alert box could indicate a successful or positive action.
Info! This alert box could indicate a neutral informative change or action.
Warning! This alert box could indicate a warning that might need attention.
Danger! This alert box could indicate a dangerous or potentially negative action.
Balaji PalaniRank #4,480 · 341 reputationPosted Jun 1, 2016, 3:21 AM EDT
Farhan ShariffRank #2,004 · 725 reputationPosted Jun 2, 2016, 12:27 PM EDT
public class MvcApplication : System.Web.HttpApplication
{
Server.ClearError();
Response.Redirect("/Home/Error");
}
}