In my ASP.NET MVC5 Application, I have created admin area. In my admin area I have controller for post with Action method as.
In my admin area, I have a created layout page _Layout.cshtml in this I have implemented materializesCSS tabs. I have a Controller by name Article, Author etc, in same admin area which is implementing CRUD operation, I need to fill tabs with Create Views from different controller. Example Create View of Author to Create new Author Create View from Article for Creating new Article etc.
This is what I have done so far:
//Layout code
@{ RenderBody(); } // This is to ignore RenderBody
<main>
<div class="container">
<div class="card hoverable">
<div class="row">
<div class="col s12">
<ul id="tabs-swipe-demo" class="tabs">
<li class="tab col s3"><a class="active" href="#test-swipe-1">+ Article</a></li>
<li class="tab col s3"><a href="#test-swipe-2">+ Create Author</a></li>
<li class="tab col s3"><a href="#test-swipe-3">+ Create New Article</a></li>
</ul>
<div id="test-swipe-1" class="col s12">
@{ Html.RenderAction("Create","Author");} </div>
<div id="test-swipe-2" class="col s12 red">
@{ Html.RenderAction("Create","Article");} </div>
</div>
</div>
</div>
</div>
</main>
//Controller Code:
public class ArticleController : Controller
{
// GET: Admin/Article
DbContext db = new DbContext();
public ActionResult Create()
{
return View(); // to reduce complexity I have kept this code bare minimum to return view
}
}
//View Code:
@using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder
@model Proj.Models.Article
@{
ViewBag.Title = "New Article";
}
@using (Html.BeginForm("create", "Article"))
{
<div class="row">
<div class="input-field col s12">
@*@Html.LabelFor(m=>m.Title)*@
@Html.TextBoxFor(m => m.Title, new
{
@class = "validate",
@placeholder = "Enter Title",
@requried = "required"
})
</div>
</div>
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">mode_edit</i>
@Html.TextAreaFor(m => m.ArticleBody, new
{
@class = "materialize-textarea",
@id = "textarea1",
@placeholder = "ArticleBody",
@requried = "required",
@maxlength = 900,
data_length = "900"
})
</div>
</div>
<button class="btn waves-effect waves-light" type="submit" name="action">
Submit
<i class="material-icons right">send</i>
</button>
}
When I execute this I get the following error:
An unhandled exception of type
System.StackOverflowExceptionoccurred inmscorlib.dll
System.StackOverflowException was unhandled
HResult=-2147023895
Message=Exception of type 'System.StackOverflowException' was thrown.
InnerException:
RenderBody is muted out on purpose if I use RenderBody it will load only one Create View, in other tabs I couldn’t load.