Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

problem with additional layout page

$
0
0

I would like to make a layout page based on the view shown below, with the content in the div with class "form-group" inserted in the resulting content pages. Or better yet, I'd like to make all the values after the "asp-for" and "asp-validation-for" tag helpers variable in each content page. Each content page would also have to contain a different model at the top. All this would help tremendously in my quest to make this a "DRY" project. Any hints?

PROPOSED LAYOUT PAGE:

@RenderBody()
@{await Html.RenderPartialAsync("_BeginAllPartial").ConfigureAwait(false); }<form asp-area=@ViewBag.Area asp-controller=@ViewBag.Controller asp-action=@ViewBag.Action asp-route-returnurl=@ViewData["ReturnUrl"] method="post" class="form-horizontal"><input type="hidden" asp-for="ID" />

    @{await Html.RenderPartialAsync("_FormBeginPartial").ConfigureAwait(false); }<div class="form-group"><div class="form-inline"><label asp-for=@RenderSection("ctrl01Label", required: true) class="control-label col-md-3"></label><input asp-for=@RenderSection("ctrl01Input", required: true) class="form-control col-md-offset-1 col-md-4" autofocus tabindex="10" /></div></div>


    @{await Html.RenderPartialAsync("_FormEndPartial").ConfigureAwait(false); }</form>

@{await Html.RenderPartialAsync("_EndAllPartial").ConfigureAwait(false); }


PROPOSED CONTENT PAGE:

@model InstructionalMaterialViewModel
@Layout="_CreateEditLayout"

@section ctrl01Label{"Isbn"}
@section ctrl01Input{"Isbn"}

Following is the error I get; I also find it strange that the term "section" didn't Intellisense for me.

An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.

/Features/Shared/Lookup/_CreateEditLayout.cshtml

An expression tree may not contain a named argument specification
<label asp-for=@RenderSection("ctrl01Label", required: true) class="control-label col-md-3"></label>
An expression tree may not contain a named argument specification
<input asp-for=@RenderSection("ctrl01Input", required: true) class="form-control col-md-offset-1 col-md-4" autofocus tabindex="10" />

Generated Code

An expression tree may not contain a dynamic operation
#pragma warning restore 199


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>