[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Clickable <tr> tag

Posted on 2012-09-17
6
Medium Priority
?
545 Views
Last Modified: 2012-09-23
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
Comment
Question by:jeffiepoo
  • 3
  • 2
6 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38407422
I don't know about the .net stuff, but all the browser needs is an onclick event:

<tr onclick="somescript();">


Cd&
0
 
LVL 6

Author Comment

by:jeffiepoo
ID: 38407442
Well I suppose then if you could tell me how to call an actionlink from Javascript you'd get the points!
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38407493
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Accepted Solution

by:
jeffiepoo earned 0 total points
ID: 38407674
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
 
LVL 9

Expert Comment

by:darjimaulik
ID: 38408991
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
 
LVL 6

Author Closing Comment

by:jeffiepoo
ID: 38426052
This solved my issue thanks.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question