下面怎么做動態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>
uj5u.com熱心網友回復:
您可以傳遞引數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)
您可以查看此檔案以供參考
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/459890.html
標籤:javascript C# html asp.net-mvc
上一篇:MVC-計數記錄數
