[英]Passage of values between pages razor, asp.net Core 2.2
'm doing a page with asp.net 2.2 and c #. 正在使用ASP.NET 2.2和C#制作页面。 I have 3 pages Razor. 我有3页剃刀。 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). 人员和活动都是带数据库数据sql的简单类(对此我没有任何问题)。 I tried to pass the ID with: 我尝试通过以下方式传递ID:
<a asp-route-id="@item.Id" asp-page="Formulario" class="btn btn-success btn-sm">Selecionar</a>
There are different ways... 有不同的方法...
1. URL Segments: 1. URL段:
www.mydomain.tld/mypage/myparam
In the code of mypage: 在mypage的代码中:
var myparam= Request.Url.Segments[3];
2. URL Parameter 2. URL参数
www.mydomain.tdl/mypage/?urlparam=myparam
In the code of mypage: 在mypage的代码中:
var myparam = Request.Params["urlparam"];
3. Session Variables 3.会话变量
Session["myparam"]=myparam
every other page: 每隔一页:
myparam= Session["myparam"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.