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??
<div class="container body-content">
@RenderBody()
@RenderSection("alertmethod")
<footer>
</footer>
</div>
-
-
-
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
{
<script src="https://cdnjs.cloudflare.com/ajax/libs/AlertifyJS/1.13.1/alertify.min.js" type="text/javascript">
$(function () {
var successmessage = '@ViewBag.message'
if (successmessage != '') //means aani '' length=0 ni alava hovu joiye
{
alertify.success(successmessage);
}
});
</script>
}
How to resolve this issue??