Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is it possible?

@Html.ActionLink( "Link text", "Action Name", new { id = *JAVASCRIPT VARIABLE* })

Please explain with example code.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
515 views
Welcome To Ask or Share your Answers For Others

1 Answer

It actually is very much possible with the following:

var hello = "Great Job!";

var text = "@Html.ActionLink( "Link text", "Action Name", new { id = "JSVar" })"
text = text.replace("JSVar",hello);

As easy as that! :)

All the @Html.Action link does is create a url string so doing replace on it is the same as replace on any javascript string


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...