1
Within people, I own the accounts receivable table, where I am calling the accounts receivable create page, and Edit. So far, it’s working perfectly.
However, within receivables, I have one select
, where I already wanted to come selected the person I was. And also has the return list.
I needed to know how I can do, for example, passing a parameter, whether it is being called accounts receivable or people, for, when returning, I do the treatment to know where to return.
Here is the create:
<a asp-page="/ContaReceber/Create" class="btn btn-primary btn-sm">Criar nova Conta</a>
And here the Edit:
<a asp-page="/ContaReceber/Edit" asp-route-id="@item.Id" class="btn btn-sm btn-success">Editar</a>
He redirects, but I need to treat, as I reported.
This is the person ID parameter I need to pass to the other page:
<input type="hidden" asp-for="PessoaVM.Pessoas.Id" name="id" id="id" />
Edit: Can pass id to Contareceber/Create page this way:
<a asp-page="/ContaReceber/Create" asp-route-id="@Request.Query["id"]" class="btn btn-primary btn-sm">Criar nova Conta</a>
But I don’t know how to handle it in here:
public IActionResult OnGet()
{
ContasReceberVM = new ContasReceberViewModel
{
ContasReceber = new ContasReceber(),
PessoaVM = _context.Pessoas.ToList(),
PlanosServicos = _context.PlanosServicos.ToList()
};
return Page();
}
public IActionResult OnGet(int id)
{
ContasReceberVM = new ContasReceberViewModel
{
ContasReceber = new ContasReceber(),
PessoaVM = _context.Pessoas.Where(m => m.Id == id).ToList(),
PlanosServicos = _context.PlanosServicos.ToList()
};
return Page();
}
It returns the following error:
Multiple handlers Matched. The following handlers Matched route data and had all constraints satisfied:
Microsoft.AspNetCore.Mvc.Iactionresult Onget(), Microsoft.AspNetCore.Mvc.Iactionresult Onget(Int32)
to pass this to another page, you could use a Querystring, right? Why don’t you do that?
– Wallace Maxters
But how can I pass through ? In the case here I call the page, /Contareceber/Create and I need to pass the idpessoa, which is a Hidden.
– Mariana
@marianac_costa You don’t need to use code snippet in code that won’t run itself. In these cases you can only format the code with 4 spaces.
– Jéf Bueno
I don’t know how to do on Asp.net-core, but the idea would be:
ContaReceber/Create?PessoaId=@IDPessoaAqui
– Wallace Maxters
Yeah, the idea would be this, this I’m trying to, but I’m not getting.
– Mariana
@marianac_costa could show us what he has tried to do?
– Wallace Maxters
@Wallacemaxters edited the question. Remembering that I have the load of the create page without the parameter, and with the parameter.
– Mariana
It is already receiving the normal id, I am passing in onget(int id), but when the id comes empty, it does not load the select, I need to treat that if it is empty behind all, else it brings the id.
– Mariana
Is more or less that?
– Wallace Maxters
Let’s go continue this discussion in chat.
– Wallace Maxters