I would like to have two partial views in which I can put the beginning form tag in one and the ending in another, so that I can place content between them:
@{await Html.RenderPartialAsync("../PartialFormBegin").ConfigureAwait(false);}
@{await Html.RenderPartialAsync("_ContentCreateEdit").ConfigureAwait(false); }
@{await Html.RenderPartialAsync("../PartialFormEnd").ConfigureAwait(false); }
The following is code for the form begin and end partial views:
<form asp-area=@ViewBag.Area asp-controller=@ViewBag.Controller asp-action=@ViewBag.Action asp-route-returnurl="@ViewData["ReturnUrl"]" method="post" class="form-horizontal"><hr /><div asp-validation-summary="All" class="text-danger"></div><div class="form-group"><div class="col-md-offset-3 required form-inline"><span style="font-weight:bold;">Required field</span></div></div><div class="form-group"><div class="col-md-offset-4"><button type="submit" class="btn btn-default col-md-offset-1" tabindex="6">Save</button></div></div></form>
When I attempt to do this, however, it produces this error: Found a malformed 'form' tag helper. Tag helpers must have a start and end tag or be self closing.
Is there any other way to approach this, or do I just have to repeat the whole form each time? I'd rather be "DRY" and have it all in one partial view in case of errors, changes, etc. It would be nice if it finished reading all partial views contained therein before jumping to conclusions. I'm quite sure I was able to do something in previous WebForms versions, but surely not in this version of .Net Core MVC.