• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 548
  • Last Modified:

Clickable <tr> tag

Hey Experts,

I'm using ASP.NET MVC 3, so hopefully you can give me some clues as to how to get this to work using this framework.

I need to make the entire <tr> tag below clickable so it goes through a controller to another Show Page.

I had to implement the 'ActionLink' so that I can test out the resulting page, but it certainly isn't how I would like this page to work ---- I.E. - clickable <tr> tag.

        <tr class='@oddOrEven'>
        @Html.ActionLink(p.venue_name, "ShowDetails", new {p.ShowID})
            <td class='date'>
                <div class='date-square'>
                    <span class='date-month'>@p.start_time.ToString("MMM")<br /></span>
                    <span class='date-day'>@p.start_time.Day.ToString()<br /></span>
                    <span class='date-year'>@p.start_time.Year.ToString()</span>
                </div>
            </td>
            <td class='venue'><!--Venue and Address and venue webpage-->
                <div class='venue-name'><a href="@p.venue_webpage">@p.venue_name</a></div>
                <span class='venue-address'>@p.venue_address <a href="@p.google_address_webpage" alt="Map to Venue" class='Map'>Google Map</a></span><!--Google maps link?-->
            </td>
            <td class='additional'><!--All Ages?, set time, ticket price-->
                <div class='age-group'>@p.age_group</div>
                <div class='time'>Set: @p.start_time.ToString("h:mm tt")</div>
                <div class='doors'>Doors: @p.doors_time.ToString("h:mm tt")</div>
                <span class='ticket-price'>Tickets: @p.ticket_price$</span>
            </td>
        </tr>

Open in new window

0
jeffiepoo
Asked:
jeffiepoo
  • 3
  • 2
1 Solution
 
COBOLdinosaurCommented:
I don't know about the .net stuff, but all the browser needs is an onclick event:

<tr onclick="somescript();">


Cd&
0
 
jeffiepooAuthor Commented:
Well I suppose then if you could tell me how to call an actionlink from Javascript you'd get the points!
0
 
COBOLdinosaurCommented:
Like I said I don't know about the .net stuff, I work in the open source world where we just generate the code to do what needs to be done, and there is clear separation of client side and server side operations.

Cd&
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
jeffiepooAuthor Commented:
Check it:

http://www.codeproject.com/Tips/198477/Calling-a-MVC-Controller-and-Action-Method-using-H

Changed to:

        <tr class='@oddOrEven' onclick="location.href='@Url.Action("ShowDetails", "Show", new { p.ShowID })'">

Open in new window

0
 
darjimaulikCommented:
Yes the code works.


<table border="1" cellpadding="0" cellspacing="0">
            @{ var odd = true; }
 @for (int i = 0; i < 10; i++)
			{
		 <tr class="@(odd ? "odd": "even")" onclick="location.href='@Url.Action("Index", "Candidate")'">

         <td>
            Test
         </td>

		 <td>
         	 @Html.TextBox("Textbox" + i) <br />
		</td>

	</tr>
      odd = !odd;
            }
</table>

Open in new window

0
 
jeffiepooAuthor Commented:
This solved my issue thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now