Note that there are some explanatory texts on larger screens.

plurals
  1. PORemoving a Partial View in MVC
    primarykey
    data
    text
    <p>I have a View with Name, CreatedDate, Address, etc. In the Address section I have State, City etc. I made this section a Partial View.</p> <p>By default there will be one address section in mainView. I have a button "AddAddress". I want to add another address section if user clicks the button (add a partial view). After getting this partial view there should be a remove button to remove this partial view. I am not using Razor.</p> <p>the following code is my Javascript to delete my address.</p> <pre><code> function deleteAddress(addressId, clientId) { var url1 = "/Client/DeleteAddress"; if (confirm("Are you sure you want to delete this address?")) { var result = false; $.ajax({ url: url1, type: 'POST', async: false, data: { AddressId: addressId, ClientId: clientId }, dataType: 'json', success: function (data) { result = data; }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert("XMLHttpRequest=" + XMLHttpRequest.responseText + "\ntextStatus=" + textStatus + "\nerrorThrown=" + errorThrown); } }); if (result) { } } } </code></pre> <p>the following code is in my controller.</p> <pre><code> [HttpPost] public JsonResult DeleteAddress(int AddressId, int ClientId) { if (AddressId != 0) { if (ClientId != 0) { ClientService.Client clientVuTemp = new ClientService.Client(); clientVuTemp = (ClientService.ClientView)TempData["EditClientData"]; clientVuTemp.Address.RemoveAt(AddressId); //soft delete clientVuTemp.Address[AddressId].IsActive = false; _clientSvc.InserOrUpdateClientAddresses(clientVuTemp.Address); } else { } return Json(true); } else return Json(false); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload