यहाँ एक उदाहरण विधि है मुझे लगता है कि मेरे ऐप से एक रिकार्ड को हटा देता है:ASP.NET MVC दिखाएँ सफलता संदेश
[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");
}
मुझे क्या करना चाहते हैं ऐसा ही कुछ कहते हैं सूचकांक दृश्य पर एक संदेश दिखाने है : "Lorem ipsum आलेख हटा दिया गया है" मैं यह कैसे करूँगा? धन्यवाद
यहाँ मेरे वर्तमान सूचकांक विधि है, अगर:
// 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);
}
मैं एक nuget पैकेज है कि देखने के लिए (त्रुटि, चेतावनी, जानकारी और सफलता) नियंत्रक से संदेश भेजने में मदद करता है बनाया बूटस्ट्रैप के लिए तैयार है: https://www.nuget.org/पैकेज/बूटस्ट्रैप नोटिफिकेशन/ –