2017-07-08 21 views
0

我需要從DetailsController從我DetailsView控件處理服務器上的東西,然後我需要返回到DetailsView控件,但我需要顯示新在新的視圖窗口與進步的信息(DetailsPrint)太,所以,任何想法我可以做到這一點?如何從控制器MVC ASP打開一個新標籤或窗口

注:是強制性的進入服務器,所以

@Html.ActionLink("linkText", "Action", new {controller="ControllerName"}, new {target="_blank"}) 

<button onclick="location.href='@Url.Action("Edit", "Home",new { Model.ID })';return false;">Detail</button> 

    <input type="button" title="Delete" value="D" onclick="location.href='@Url.Action("Edit", "Home", new { id = item.ID })'" /> 

不適合我的工作

+0

如何在後行動在視圖中添加'window.open'腳本? – hardkoded

回答

1

動作鏈接必須爲你正確編碼,有目標= _blank到打開一個新窗口。
同時,必須提供一個參數給DetailsController,讓他知道他必須返回DetailsPrint視圖而不是正常的DetailsView。

您可以通過查詢字符串提供此參數

@Html.ActionLink("linkText", "Action?print=true", new {controller="ControllerName"}, new {target="_blank"})