Monday, June 3, 2024
41
rated 0 times [  42] [ 1]  / answers: 1 / hits: 40126  / 13 Years ago, mon, may 23, 2011, 12:00:00
@(Html.ActionLink(Link Label, 
ActionMethodName,
ControllerName,
null, // parameter object, then html object
null))


produces



<a href=/ControllerName/ActionMethodName/>Link Label</a>


If I want to reference the /ControllerName/ActionMethodName/id in a JavaScript template for the Edit or New link, how would I assign that to a JavaScript variable?



attempt:



<script type=text/javascript>
var actionUrl = '@(Html.ActionLink(,ActionMethodName,
ControllerName,null,null))';
</script>


but at that point, I would have to use Javascript to remove the unwanted <a href... characters in the string.


More From » asp.net-mvc-3

 Answers
15

@Url.Action(ActionMethodName, ControllerName) will generate a path.


[#92109] Friday, May 20, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ammonjesseg

Total Points: 170
Total Questions: 110
Total Answers: 98

Location: Benin
Member since Fri, Mar 24, 2023
1 Year ago
;