如何进行下面的动态href?
@Model.inbox_type是一个动态值;1〃"2〃"3〃"6〃;,如何使用下面的href?
<button class="btn btn-block btn-secondary" type="button" onclick="location.href='@Url.Action("Index/" + "@Model.inbox_type" , "Inbox")'">Exit</button>
您可以在Url.Action
上传递参数,而不是附加字符串的
<button class="btn btn-block btn-secondary" type="button" onclick="location.href='@Url.Action("Index", "Inbox", new { id: @Model.inbox_type })'">Exit</button>
注意,id
是您在动作函数中期望的参数
public ActionResult Index(string id)
您可以查看此文档以获取参考