Solved

How Do You Attach an Onclick event to @Html.ActionLink

Posted on 2014-09-05
3
4,285 Views
Last Modified: 2014-09-11
I need to attach an onclick event to @Html.ActionLink.

Here is my code:
Html.ActionLink(item.Parameters, "ViewResults", new { id = "1122", onclick="javascript:VehicleLoad();return false;" })

I cannot get the onclick event to activate.

Dan
0
Comment
Question by:danielolorenz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:danielolorenz
ID: 40306414
Corrected code:
Html.ActionLink(item.Parameters, "ViewResults", new { id = "1122", onclick="javascript:VehicleLoad();return false;" })
0
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 500 total points
ID: 40307163
<%= Html.ActionLink("linky", "action", "controller", new { onclick = "someFunction();"}) %>
0
 

Author Closing Comment

by:danielolorenz
ID: 40317640
Thanks.

Excellent response.
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

724 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