Aquí está un ejemplo de método Tengo que elimina un registro de mi aplicación:ASP.NET MVC Mostrar mensaje de éxito
[Authorize(Roles = "news-admin")]
public ActionResult Delete(int id)
{
var ArticleToDelete = (from a in _db.ArticleSet where a.storyId == id select a).FirstOrDefault();
_db.DeleteObject(ArticleToDelete);
_db.SaveChanges();
return RedirectToAction("Index");
}
Lo que me gustaría hacer es mostrar un mensaje en la vista de índices que dice algo como : "El artículo de Lorem ipsum ha sido eliminado" ¿cómo podría hacer esto? Gracias
Aquí es mi método de índice actual, por si acaso:
// INDEX
[HandleError]
public ActionResult Index(string query, int? page)
{
// build the query
var ArticleQuery = from a in _db.ArticleSet select a;
// check if their is a query
if (!string.IsNullOrEmpty(query))
{
ArticleQuery = ArticleQuery.Where(a => a.headline.Contains(query));
//msp 2011-01-13 You need to send the query string to the View using ViewData
ViewData["query"] = query;
}
// orders the articles by newest first
var OrderedArticles = ArticleQuery.OrderByDescending(a => a.posted);
// takes the ordered articles and paginates them using the PaginatedList class with 4 per page
var PaginatedArticles = new PaginatedList<Article>(OrderedArticles, page ?? 0, 4);
// return the paginated articles to the view
return View(PaginatedArticles);
}
he creado un paquete de Nuget que ayuda con el envío de mensajes (error, advertencia, información y el éxito) desde el controlador para ver que es Bootstrap listo: https://www.nuget.org/packages/BootstrapNotifications/ –