2015-12-16 51 views
1

我需要Razor @ Html.ActionLink將數據從一個頁面傳遞到另一個頁面。跳轉鏈接是這樣的:使用Razor傳遞數據ActionLink

@Html.ActionLink("Add to Plan","Index","Plan", null, new {@id="submit", @name="submit", @class="slider-btn"}) 

我有這樣一個值:

<input type="hidden" id="searchbar" name="searchbar" value="some_value" /> 
+0

更換你的'的ActionLink的第四個參數()'與你想傳遞的數據 - 例如'@ H​​tml.ActionLink(「Add to Plan」,「Index」,「Plan」,new {searchbar =「some_value」},new {...})'。 –

回答

3

應該使用這個......

@Html.ActionLink("Add to Plan","Index","Plan", new { searchbar = "some_value" }, new { ... })