Html.RenderAction从管理区域进入'实现CSS'标签

时间:2017-10-21 05:05:59

标签: asp.net asp.net-mvc-5 partial-views renderaction

在我的ASP.NET MVC5应用程序中,我创建了管理区域。在我的管理区域,我有控制器用于发布Action方法。

在我的管理区域中,我有一个已创建的布局页面_Layout.cshtml,我已经实现了materializesCSS个标签页。我有一个名称为ArticleAuthor等的控制器,在实现CRUD操作的同一个管理区域中,我需要填写来自不同控制器的创建视图的选项卡。示例创建作者视图以创建新作者创建视图以创建新文章等

这是我到目前为止所做的:

//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>

//控制器代码:

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
      }
  }

//查看代码:

@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>
}

当我执行此操作时,我收到以下错误:

  

System.StackOverflowException

中发生了mscorlib.dll类型的未处理异常
System.StackOverflowException was unhandled
  HResult=-2147023895
  Message=Exception of type 'System.StackOverflowException' was thrown.
  InnerException:

如果我使用RenderBody,RenderBody会故意静音,它只会加载一个Create View,而在其他标签中我无法加载。

0 个答案:

没有答案