I have a Folder named MenuItem in my project which has a page called Upsert.In upsert page ,both edit and create functionality is worked,but when I click on edit button, I face with this error:No webpage was found for the web address: https://localhost:44332/Admin/MenuItem/upsert?id=1.But when I click on create button,everything is okay. Here is my code for Upsert.cshtml:
@page
@model PracticeWithVideo.Pages.Admin.MenuItems.UpsertModel
<form method="post" enctype="multipart/form-data">
<div class="border p-3 mt-4">
<div class="row pb-2">
<div class="col-9">
</div>
<h2 class="text-primary pl-3">
@(Model.MenuItem.Id!=0 ? "Update": "Create") Menu Item
</h2>
<hr />
<div class="mb-3">
<label asp-for="MenuItem.Name"></label>
<input asp-for="MenuItem.Name" class="form-control" />
<span asp-validation-for="MenuItem.Name" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="MenuItem.Description"></label>
<textarea asp-for="MenuItem.Description" class="form-control"></textarea>
<span asp-validation-for="MenuItem.Description" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="MenuItem.Price"></label>
<input asp-for="MenuItem.Price" class="form-control" />
<span asp-validation-for="MenuItem.Price" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="MenuItem.Image"></label>
<input type="file" name="files" id="uploadBox" class="form-control" />
</div>
<div class="mb-3">
<label asp-for="MenuItem.CategoryId"></label>
<select asp-for="MenuItem.CategoryId" asp-items="Model.CategoryList" class="form-select">
<option disabled selected>-Select Category-</option>
</select>
<span asp-validation-for="MenuItem.CategoryId" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="MenuItem.FoodTypeId"></label>
<select asp-for="MenuItem.FoodTypeId" asp-items="Model.FoodTypeList" class="form-select">
<option disabled selected>-Select FoodType-</option>
</select>
<span asp-validation-for="MenuItem.FoodTypeId" class="text-danger"></span>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary" style="width:150px;"> @(Model.MenuItem.Id != 0 ? "Update" : "Create")</button>
<a asp-page="Index" class="btn btn-secondary" style="width:150px;">Back to List</a>
</div>
</form>
@section Scripts{
<script>
tinymce.init({
selector: 'textarea',
plugins: 'anchor autolink charmap codesample emoticons image link lists media searchreplace table visualblocks wordcount checklist mediaembed casechange export formatpainter pageembed linkchecker a11ychecker tinymcespellchecker permanentpen powerpaste advtable advcode editimage tinycomments tableofcontents footnotes mergetags autocorrect typography inlinecss',
toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table mergetags | addcomment showcomments | spellcheckdialog a11ycheck typography | align lineheight | checklist numlist bullist indent outdent | emoticons charmap | removeformat',
tinycomments_mode: 'embedded',
tinycomments_author: 'Author name',
mergetags_list: [
{ value: 'First.Name', title: 'First Name' },
{ value: 'Email', title: 'Email' },
]
});
</script>
@{
<partial name="_ValidationScriptsPartial"/>
}
}
I used upsert page which has both edit and create functionality and it differentiate by a if condition.But create is worked and edit didnt work.