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??
Laxmidhar SahooPosted Dec 29, 2019, 12:33 AM
jatin jatinPosted Dec 28, 2019, 2:16 AM
@Laxmidhar Sahoo @salman beg
Laxmidhar SahooPosted Dec 28, 2019, 12:12 AM
Salman BegPosted Dec 28, 2019, 12:11 AM