Parameters between pages (ASP.NET Core / C #)

0

Hello, I have a question that I have researched a lot and did not get any concrete answers. I am a beginner in C # and ASP.NET, forgive me for ignorance.

I have an ASP.NET Core MVC project.

In it I have Page A and Page B.

On Page A I have a "Add Page Item B" button, on which when clicking, I need to go to Page B by loading Page ID A.

I would like to know if there is any way to do this without using JS.

    
asked by anonymous 28.12.2017 / 20:49

1 answer

0

I was able to solve by putting the following function onclick on the button:

onclick="location.href='@Url.Action("Action", "Controller")/'+$('#IdPai').val()"

So, in Controller Action I get an id as a parameter and within the method I create a new object with the id in question. See an example of how it got in the controller

public IActionResult Create (int id = 0) {
    var Objeto = new ObjetoViewModel();
    Objeto.IdExterno = id;
    return View(objeto);
}
    
30.12.2017 / 00:48