Bootstrap 4 从下拉菜单向同一url发送参数
我正在尝试让多个菜单链接访问同一个razor页面,但发送不同的参数以从数据库返回不同的结果 通常我只会将该值附加到查询字符串,并在单击新页面链接时检索它,但我不知道razor页面是如何做到这一点的。 例如,我想转到名为CourseList.cshtml的razor页面,并将pass、Accounting作为值,这样我只能返回会计课程Bootstrap 4 从下拉菜单向同一url发送参数,bootstrap-4,razor-pages,Bootstrap 4,Razor Pages,我正在尝试让多个菜单链接访问同一个razor页面,但发送不同的参数以从数据库返回不同的结果 通常我只会将该值附加到查询字符串,并在单击新页面链接时检索它,但我不知道razor页面是如何做到这一点的。 例如,我想转到名为CourseList.cshtml的razor页面,并将pass、Accounting作为值,这样我只能返回会计课程 asp-page="/CourseList?ccat=accounting" 我知道我可以为每个课程类别创建单独的课程列表页面,但这听起来很脏,而且随着新类别的添
asp-page="/CourseList?ccat=accounting"
我知道我可以为每个课程类别创建单独的课程列表页面,但这听起来很脏,而且随着新类别的添加,维护会更高
<ul class="navbar-nav flex-grow-1">
<li class="nav-item dropdown">
<a class="nav-link text-dark dropdown-toggle"
href="#" id="navbaddrop" data-toggle="dropdown">
Courses
</a>
<div class="dropdown-menu">
<a class="dropdown-item" asp-page="/CourseList?ccat=accounting">Accounting</a>
<a class="dropdown-item" asp-page="/CourseList?ccat=general">General</a>
<a class="dropdown-item" asp-page="/CourseList?ccat=it">IT</a>
<a class="dropdown-item" asp-page="/CourseList?ccat=manufacturing">Manufacturing</a>
</div>
</li>
</ul>
如果希望该值出现在查询字符串中,请将其传递给锚定标记帮助器的asp route-*
参数:
这正是我所需要的!非常感谢你。我已经做了很长时间的经典asp和asp.net,以至于我都在绞尽脑汁地研究这些新东西。这很有帮助。
@page "{ccat}"
CourseList/accounting
CourseList/general
public class CourseListModel : PageModel
{
[BindProperty(SupportsGet=true)]
public string Ccat { get; set; }
...