1

I have a role based @html.ActionLink() .Which show or hide link based on user permission.ASP.NET MVC5 Default @html.ActionLink() works fine.

But i want to pass angularjs value as a route value.

  @Html.ActionLink("Edit", "Edit", "Branches", new { id = "{{branch.BranchId}}" })

but this code render following code

<a href="/Branches/Edit?Length=8" id="22">Edit</a>

i found this link but can't find a solution. @Html.ActionLink and Angularjs value? I want to pass angularjs value using actionLink() not Url.Action()

Thanks

Ironman
  • 243
  • 1
  • 4
  • 15
  • try this @Html.ActionLink("Edit", "Edit", "Branches", new { id = "{{branch.BranchId}}" },null) – Praveen Maurya Dec 14 '17 at 12:05
  • yes already tried this . not working :( . – Ironman Dec 14 '17 at 12:55
  • this won't work. the `Html.ActionLink` is rendered server side, while Angularjs is rendered client side. At the time the `ActionLink` is created, the information from the expression would not be available. – Claies Dec 14 '17 at 14:02

1 Answers1

1

This could work for you. Just remove the controller name from the parameters.

@Html.ActionLink("Edit", "Edit", new { id = "{{branch.BranchId}}" })

Or like this with controller name

@Html.ActionLink("Edit", "Edit", "Branches", new { id = "{{branch.BranchId}}" }, null)

Or you can try this

@{
     var link = Url.Action("Edit", "Branches", new { id = "{{branch.BranchId}}" });
     link = HttpUtility.UrlDecode(link);
 }
 <a href="@link">Edit</a>
Nitesh Kumar
  • 1,774
  • 4
  • 19
  • 26