Skip to content
Loading
how to return bootstap 5 model as view from controller?

        

    

    

    

    

    

        $(function () {          

            $("#CustomerGrid .details").click(function () {

                var customerId = $(this).closest("tr").find("td").eq(0).html();

                $.ajax({

                    type: "POST",

                    url: "/Home/Details",

                    data: '{customerId: "' + customerId + '" }',

                    contentType: "application/json; charset=utf-8",

                    dataType: "html",

                    success: function (response) {

                        $("#partialModal").find(".modal-body").html(response);

                        $("#partialModal").modal('show');

                    },

                    failure: function (response) {

                        alert(response.responseText);

                    },

                    error: function (response) {

                        alert(response.responseText);

                    }

                });

            });

        });

    

 

In Partial View

@model Partial_View_MVC.Customer

    

        @Html.DisplayNameFor(model => model.Address):

        

            @Html.DisplayFor(model => model.Address)

            

            @Html.DisplayFor(model => model.City),

            @Html.DisplayFor(model => model.PostalCode)

            

            @Html.DisplayFor(model => model.Country)

        

    

  • Pasang Tamang

    Below link will gives you more explanation about using partial view as Boootstrap modal

    https://www.aspsnippets.com/Articles/Render-Partial-View-inside-Bootstrap-Modal-Popup-in-ASPNet-MVC.aspx

  • Pasang Tamang

    Hi,

    You should be able to load partial view as a Bootstrap modal. Please check code example from below link.

    https://gist.github.com/shaneprice/bc69d6e318b063493948

     

    Regards,
    Pasang