I used ViewComponent to display multiple photos in post edit view. But when the photos are loaded on the page, instead of going through that ViewComponent,again, it returns id with zero value and sends it to the controller and gives an error. where is the problem from?
@model DataLayer.Models.ViewModels.Post.ShowPostListItemViewModel @{ ViewData["Title"] = "Post Edit"; } <div class="row"> <form method="post" asp-action="EditPost" enctype="multipart/form-data"> <input type="hidden" asp-for="PostId" /> <div class="col-lg-12 col-md-12 col-sm-12"> <h1 class="page-header">Edit Post</h1> </div> <div class="row "> <div class="col-md-8 col-sm-8 col-lg-8"> <div class="panel panel-primary"> <div class="panel-body col-md-12 col-sm-12"> <div class="form-group col-md-6 col-sm-6"> <label>Title</label> <input type="text" asp-for="Title" class="form-control" /> </div> <div class="form-group col-md-6 col-sm-6"> <label>Category</label> <select type="text" asp-for="GroupId" asp-items="@(ViewData["Groups"] as SelectList)" class="form-control"></select> </div> <br /> <br /> <br /> <div class="form-group col-md-12 col-sm-12"> <label>PostDescription</label> <textarea id ="Post_PostDescription" class="form-control" asp-for="Description" rows="10"></textarea> </div> </div> </div> </div> <div class="col-md-4 col-sm-4 col-lg-4"> <div class="panel panel-default "> <!-- /.panel-heading --> <div class="panel-body col-md-12 col-sm-12 col-lg-12"> @await Component.InvokeAsync("EditPostImageComponent",@Model.PostId) <div class="col-md-4"> <p></p> <div class="form-group"> <label>Select Image</label> <input type="file" name="imgPostUp" id="imgPostUp" multiple="multiple"> </div> </div> </div> <!-- /.panel-body --> </div> </div> <div class="col-md-12 col-sm-11"> <p> <input type="submit" value="Edit" class="btn btn-success" /> <a href="~/Admin/Post/GetPost" class="btn btn-danger ">Back</a> </p> </div> </div> </form> </div> @section Scripts { <script> $("#imgPostUp").change(function () { readURL(this); }); </script> <script src="https://cdn.ckeditor.com/4.9.2/standard/ckeditor.js"></script> <script> CKEDITOR.replace('Post_PostDescription', { customConfig: '/js/Config.js' }); </script> }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)