0
votes

'm doing a page with asp.net 2.2 and c #. I have 3 pages Razor. One with a form and two others, one with a search engine and another with an activity search engine. Using a button from the form redirected to the other two. What I am not able to do is pass the values ​​(through a selection button) name and age of the personnel page and the same with the activity and the number of hours per week. Both the staff and the activities are simple classes that bring the database data sql (for this I have no problems). I tried to pass the ID with:

<a asp-route-id="@item.Id"  asp-page="Formulario" class="btn btn-success btn-sm">Selecionar</a>
1
How do I get that value to be able to use it, and especially how can I consolidate it so that it is not deleted when I receive another data from the other view? Thank you - ignacio blanco gonzalez
You can add the values to your page's route template and use model binding to retrieve them. Read about Route Data: learnrazorpages.com/razor-pages/routing#route-data and Model Binding in Razor Pages: learnrazorpages.com/razor-pages/model-binding - Mike Brind
@RahulSharma There are no controllers or views in Razor Pages - Mike Brind
@MikeBrind Ohh I am sorry. My understanding was that the form is submitted to a Controller action method and based on that the redirection could be done with the parameters. - Rahul Sharma

1 Answers

-1
votes

There are different ways...

1. URL Segments:

www.mydomain.tld/mypage/myparam

In the code of mypage:

var myparam= Request.Url.Segments[3];

2. URL Parameter

www.mydomain.tdl/mypage/?urlparam=myparam

In the code of mypage:

var myparam = Request.Params["urlparam"];

3. Session Variables

Session["myparam"]=myparam

every other page:

myparam= Session["myparam"]