并且需要将groupId传递给JS函数Approve()该行给出了一个错误:NewLine in constant。第二个 %> 以黄色突出显示,但不是 Approv-6ren">
gpt4 book ai didi

javascript - 通过传递参数从 html.actionlink 调用 JS

转载 作者:行者123 更新时间:2023-11-30 18:10:02 26 4
gpt4 key购买 nike

我有这一行:

<%: Html.ActionLink(item.Name, "Group", "Recommend", new { area = "User" , groupId = item.GroupId, onclick = "Approve(<% groupId %>)" } ) %>

并且需要将groupId传递给JS函数Approve(<% groupId %>)该行给出了一个错误:NewLine in constant。第二个 %> 以黄色突出显示,但不是 Approve (<% groupId %>) 中的第一个。我是否缺少标签或引号?

谢谢

最佳答案

尝试这样的事情:

<%: Html.ActionLink(item.Name, "Group", "Recommend", new %>
<%: { %>
area = "User" ,
groupId = item.GroupId,
onclick = "Approve(" + item.GroupId + ")"
<%: } ) %>

关于javascript - 通过传递参数从 html.actionlink 调用 JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14827236/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com