0

Say I have a javascript dictionary variable with the following key value pairs:

var attributes = { name : "name1", age: 10}

I want to use the values in the above attribute to create the children of an HTML ul element within the same javascript function as follows:

var htmlContent = '<ul><li>@Html.ActionLink(attributes["name"], "Details", "Home", new { name = attributes["name"]})</li></ul>'

Is there a way to do this? TIA.

1 Answer 1

2

I'm not sure you can use the JavaScript attributes variable in the @Html.ActionLink?

I'd recommend changing it to

var htmlContent = '<ul><li><a href="@Url.Action("Details", "Home")" name="' +
    attributes.name + '">Link</a></li></ul>';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.