asp.net mvc 3 razor. navigate to view on table tr click

瘦欲@ 提交于 2020-01-10 20:24:06

问题


I have users list table how i can navigate on url: "../users/showprofile?userid="

I want to make table when user clicks on table row navigate on current user profile

Thanks


回答1:


Without using jQuery, assuming you're in a foreach loop like something below, just change the tr definition to be something like:

@foreach (var user in Model.Users)
{
    <tr onclick="location.href = '@(Url.Action("ShowProfile", "Users", new { userId = user.UserId }))'">
    //rest of your markup for that table row
    </tr>
}


来源:https://stackoverflow.com/questions/10470590/asp-net-mvc-3-razor-navigate-to-view-on-table-tr-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!