Answers for "asp.net core 3.1 change data on bootstrap modal window using EF"

2

asp.net core 3.1 change data on bootstrap popup window using EF

<!--   This exemple is using EF and JQuery -->

<!-- Index View -->
<a id="edit" onclick="editProduct(@item.id)" >Edit</a>

<div id="modalEdit">
	...
</div>

<script>
    function editProduct(id) {
        $("#modalEdit").modal('show');
		//Add some more cofing
        $('#modalEdit >  div > div > .modal-body')
        //What the method load() will do its go to Controller/Edit
      	//Do the stuff and load the view into the modal-body
        .load('@Url.Action("Edit", "Posto")/' + id);
    }
</script>


<!-- Edit view code -->
@{
    Layout = null;
}
<!-- This code will be loaded inside of model-body -->
<form asp-action="Edit">
    <div asp-validation-summary="ModelOnly" class="text-danger"></div>
    <input type="hidden" asp-for="idPosto" />
    <div class="form-group">
        <label asp-for="Name" class="control-label"></label>
        <input asp-for="Name" class="form-control" />
        <span asp-validation-for="Name" class="text-danger"></span>
    </div>
    <div class="form-group">
        <input type="submit" value="Save" class="btn btn-primary" />
    </div> 
</form>
Posted by: Guest on October-20-2021

Code answers related to "asp.net core 3.1 change data on bootstrap modal window using EF"

Browse Popular Code Answers by Language