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

32,289

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>
}
Share:
32,289

Related videos on Youtube

Irakli Lekishvili
Author by

Irakli Lekishvili

Updated on May 24, 2020

Comments

  • Irakli Lekishvili
    Irakli Lekishvili almost 4 years

    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

  • Irakli Lekishvili
    Irakli Lekishvili about 12 years
    it does not doing nothing. Can you help me?
  • mattytommo
    mattytommo about 12 years
    Doh sorry I missed the location.href = before it. Try my edit, it should work for you now.
  • Irf
    Irf about 8 years
    Beautiful, Works nicely!