In MVC get an error:
Section not defined: "alertmethod"
I already define that method in Index.cshtml
_Layout.cshtml
@RenderSection("alertmethod") // I define this method in index.cshtml that's yI m using rendersection??
- @RenderBody()@RenderSection("alertmethod")
HomeController
- public ActionResult create()
- {
- return View();
- }
- [HttpPost]
- public ActionResult create(studentmvcmodel stud)
- {
- ViewBag.message = "data inserted successfully";
- return RedirectToAction("Index");
- }
Index.cshtml
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@section alertmethod
{
$(function () {
var successmessage = '@ViewBag.message'
if (successmessage != '') //means aani '' length=0 ni alava hovu joiye
{
alertify.success(successmessage);
}
});
}
How to resolve this issue??

Salman BegRank #284 · 8.8K reputationPosted Dec 27, 2019, 7:11 PM EST
Laxmidhar SahooRank #383 · 6.6K reputationPosted Dec 27, 2019, 7:12 PM EST
jatin jatin6 reputationPosted Dec 27, 2019, 9:16 PM EST
@Laxmidhar Sahoo @salman beg
Laxmidhar SahooRank #383 · 6.6K reputationPosted Dec 28, 2019, 7:33 PM EST