Refresh PartialView [closed]

0

How do I update a partialview (asp. net) after I select some parent information, for example:

I have a list of invoices and a partialview on the side to show the items in this note. When selecting one of the invoices my partialview should fetch the items according to the selected note, how to do it?

    
asked by anonymous 29.12.2015 / 13:14

1 answer

2

Implement a function that uses ajax to communicate with a controller ( DetalheNotaFiscalController , for example):

function DetalharNotaFiscal(idNota) {
    $.post("/DetalheNotaFiscal/Detalhar", { id: idNota }).done(function (retorno) {
        $("#detalhe_nf").html(retorno); //id da div com a partial, recebendo o retorno da controller
    }).error(function (xhr, ajaxOptions, errorThrown) {
        alert("Erro Interno. Favor contatar o administrador.");
    });
}

In the controller:

[HttpPost]
public ActionResult Detalhar(string id)
{
    //TODO: Recuperação da nota através do id
    var model = TODO; //model da partial view

    return PartialView("Index", model);
}
    
29.12.2015 / 13:30