
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
}
}
10 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Shakti Singh DulawatPosted May 5, 2016, 8:13 AM
Farhan ShariffPosted Jun 2, 2016, 4:27 PM
public class MvcApplication : System.Web.HttpApplication
{
Server.ClearError();
Response.Redirect("/Home/Error");
}
}
Balaji PalaniPosted Jun 1, 2016, 7:21 AM
Bhuvanesh MohankumarPosted May 6, 2016, 4:04 AM
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.
Bhuvanesh MohankumarPosted May 6, 2016, 4:03 AM
Hi Marimuthu,
Are you using the Bootstrap in your MVC, if you are using BootStrap then its very simple.
mari muthuPosted May 6, 2016, 3:33 AM
Munesh SharmaPosted May 6, 2016, 1:46 AM
Shakti Singh DulawatPosted May 6, 2016, 1:45 AM
mari muthuPosted May 6, 2016, 1:09 AM
Munesh SharmaPosted May 5, 2016, 12:34 PM
@foreach (var item in ViewData.ModelState) {
if (item.Value.Errors.Any()) {
foreach (ModelError e in item.Value.Errors) {
@e.ErrorMessage
}
}
}