In my solution, I have a button that opens a query modalview. After the query, I need to return the result of the records in the form of a link. When clicking on the link, I must return to the main screen the result of the query but before changing and directing the fields to one or more that receive the same reference. I’m having two problems: The first one is that I’m unable to return the result of the query in Partialview Modal, and the second one when I send the return of the query, in enters the Javascript method that redirects the fields. Could someone help me? Follow the short code: View of Notes registration:
Banknote view
@Html.EditorFor(model => model.NOTA_NOM_DEV, new { htmlAttributes = new { @class = "form-control", value = "", size = "45", maxlength = "45", type = "hidden" } })
@Html.ActionLink("Fornecedor", "_ConPessoas", "Pessoas", new { id = 4 }, new { @class = "modal-link btn btn-default" , id = '4'})
<script type="text/javascript">
$(function () {
// Initialize numeric spinner input boxes
//$(".numeric-spinner").spinedit();
// Initalize modal dialog
// attach modal-container bootstrap attributes to links with .modal-link class.
// when a link is clicked with these attributes, bootstrap will display the href content in a modal dialog.
$('body').on('click', '.modal-link', function (e) {
e.preventDefault();
$(this).attr('data-target', '#modal-container');
$(this).attr('data-toggle', 'modal');
});
// Attach listener to .modal-close-btn's so that when the button is pressed the modal dialog disappears
$('body').on('click', '.modal-close-btn', function () {
$('#modal-container').modal('hide');
});
//clear modal cache, so that new content can be loaded
$('#modal-container').on('hidden.bs.modal', function () {
$(this).removeData('bs.modal');
});
$('#CancelModal').on('click', function () {
return false;
});
});
</script>
_Partial view de Consulta
@{ Layout = null; } @using PagedList.Mvc; @*@using SisCerinfo.Models;*@ @using (Html.BeginForm("_ConPessoas", "Notas", FormMethod.Get)) {
Pesquisa de Pessoas
CPF/CNPJ: @*@Html.EditorFor(model => model.PES_DOCID, new { htmlAttributes = new { @class = "form-control", maxlength = "14", size = "14" } })*@ ou Nome: @*@Html.EditorFor(model => model.PES_NM, new { htmlAttributes = new { @class = "form-control", maxlength = "50", size = "50" } })*@
@*@Html.ActionLink("Devedor ", "ViewConPes", "Notas", null, new { @class = "modal-link btn btn-success" })*@
@{ if (Model != null) { foreach (var item in Model) { @item.PES_NM @Html.ActionLink("Enviar", "CadNotas", null, new { onclick = String.Format("informa_pessoa({0}, '{1}', '{2}'", @item.PES_ID,'0','0')}) } } } } $(function () { $('#approve-btn').click(function () { $('#modal-container').modal('hide'); }); }); function informa_pessoa(pesid, sus_lim, sus_dt) { //var pessoa = document.forms[0].id var pessoa = HttpContext.Current.Request.RequestContext.RouteData.Values["id"].ToString() //var pessoa = document.frm.TipoPesquisa.value; //var pessoa = document.frm.TipoPesquisa.value; if (pessoa == 4) { window.opener.document.frm.NOTA_NOM_DEV.value = trim(pesnm); window.opener.document.frm.NOTA_LIM.value = trim(sus_lim); window.opener.document.frm.NOTA_DT.value = trim(sus_dt); } window.close(); }
How it’s generating HTML?
– Maicon Carraro
The code is giving the following error: Index (based on zero) must be greater than or equal to zero and smaller than the length of the argument list. In fact I assumed that the code is implemented in this way.
– Germano Sampaio
Post your javascript function
– Maicon Carraro
I found the problem, posted there
– Maicon Carraro
If possible mark the answer as the right answer to assist later users
– Maicon Carraro