Hi,
I am sorry I am totally new at .NET Core 3.1 and razor pages and there seems to be very few information about Core 3.1 and Razor.
I am trying to show a modal dialog through AJAX to add clients, but is not working, all I get is the same form duplicated:
This is my partial view (AddPartial.cshtml):
@page @model ClienteModel<div class="modalHeader"><div class="modalLogo"><asp:Image runat="server" ImageUrl="~/content/images/modal_logo.png" alt="" Width="24" style="margin-top:8px" /></div><div class="modalTitle">Add new client</div></div><form asp-page-handler="AddPartial"><div class="mppwrapper">
This is my Cliente.cshtml.cs:
public PartialViewResult OnGetAddPartial() { return new PartialViewResult { ViewName = "~/core/cliente/AddPartial", ViewData = new ViewDataDictionary<Cliente>(ViewData, new Cliente { }) }; }
This is my Cliente.cshtml:
<div id="modal-placeholder"></div><span class="m-nav__link-text" data-toggle="ajax-modal" data-url="@Url.Page("Cliente", "_AddPartial")" id="btnnewcli">Add new</span>$(function () { var placeholderElement = $('#modal-placeholder');$('[data-toggle="ajax-modal"]').on('click', function (event) { var url = $(this).data('url');$.get(url).done(function (data) { placeholderElement.html(data); placeholderElement.find('.modal').modal('show'); }); }); });
This is my model (Cliente.cs):
public class Cliente { public Int32 Id { get; set; } public string name { get; set; } }
Any ideas what could be wrong?