简体   繁体   English

在razor,asp.net Core 2.2页面之间传递值

[英]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.

相关问题 使用 Razor Pages 在 Asp.NET Core 2.2 中找不到 ViewComponent - ViewComponent not found in Asp.NET Core 2.2 using Razor Pages Asp.Net Core Razor Pages DropDownList 选定的项目值 - Asp.Net Core Razor Pages DropDownList selected item values ASP.NET Core 2.2 Razor页面MVVM查询AspNetUsers和AspNetRoles表 - ASP.NET Core 2.2 Razor Pages MVVM Query the AspNetUsers and AspNetRoles Tables ASP.NET Core 2.2 Razor Pages 为什么 OnPost() 有效,而 OnPostAsync() 无效? - ASP.NET Core 2.2 Razor Pages why does OnPost() work, but OnPostAsync() doesn't? 如何在asp.net核心剃须刀页面2.2中设置日期格式和区域性 - How to set date formats and culture in asp.net core razor pages 2.2 带ASP.NET Core 2.2的Razor页面中的嵌套/子区域 - Nested/Sub-Areas in Razor Pages w/ASP.NET Core 2.2 IIS 部署不能在 asp.net core 2.2 razor 页面中包含 wwwroot 文件夹的文件 - IIS deployment cannot contains files for wwwroot folder in asp.net core 2.2 razor pages 如何将ASP.NET Core 2.2 Razor页面与MySql数据库连接? - How to connect ASP.NET Core 2.2 Razor pages with MySql database? ASP.NET Core Razor页面的路由 - Routing for ASP.NET Core Razor Pages Razor Pages 中的 Asp.net 核心本地化 - Asp.net core Localization in Razor Pages
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM