0
I have a cshtml (view) on this page I use a typed template and inside I use a POST form, I create a div(dinamicamnete with ajax) with some components, ALL appear normal, but the button to fire an action in the controller does not work, If I leave statico the same shoots and calls the action. C# . net Core 2.1 with MVC and Bootstrap
class ReimpressaoView {
constructor(elemento) {
this._elemento = elemento;
}
_template(model) {
return ` <button asp-action="ConfirmaReimpressaoCertificadoPDF" type="submit" class="btn btn-primary">
Imprimir
</button>
<div class="jumbotron">
<div class="container">
<p class="text-justify" style="font-size:medium">O R.G. Pesquisado é Referente ao certificado emitido em <span class="badge badge-pill badge-primary" style="float:center"> ${model.dataEmissaoAntecedentes} </span></p>
<p class="text-justify" style="font-size:medium">Com o código <span class="badge badge-pill badge-primary" style="float:center">${model.codigoUnico}</span></p>
<hr />
<p class="lead" style="font-size:medium"><strong>Obs:</strong>Este certificado tem validade até a data de <span class="badge badge-pill badge-primary" style="float:center"> ${model._dataEmissaoAntecedentes}</span></p>
</div>
`;
}
update(model) {
this._elemento.innerHTML = this._template(model);
}
AJAX
enviarRgUsuarioCertificado(event) {
event.preventDefault();
if (this._inputrgReimpressao.value === "") {
alert('Favor preencher o campo RG!!');
return; }
let model = { RG: this._inputrgReimpressao.value }
$.ajax({
url: '/certificado/GetusuarioAntecedentesRG',
type: 'Post',
contentType: 'application/json',
data: JSON.stringify(model),
async: false,
success: function (response) {
dataemissao = response.dataEmissaoAntecedentes;
codigoUnico = response.codigoUnico;
}
});
}
present the code
– Leandro Angelo
Thanks, I’m new to the stack.
– Thiago Barros