我有一個鏈接巫婆我想喲改變成一個按鈕,鏈接通過,雖然參數和外觀如下:有沒有辦法通過按鈕發送參數?
@Html.ActionLink("View", "Print", new { id = item.SalesContractId })
我現在想用這個參數{ID的一個按鈕來取代它= item.SalesContractId}
我的按鈕,如下所示:
<input type="button" value="Print" id="btnFromIndexPrint" />
有人能告訴我如何我CA去這樣做?
這是我的頁面的外觀,所以你可以看到我嘗試才達到:
@model IEnumerable<Contract.Models.tbSalesContract>
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
</head>
<body>
<p>
@Html.ActionLink("Create New", "Edit")
</p>
<table>
<tr>
<th>
Company
</th>
<th>
Trading As
</th>
<th>
Created
</th>
<th>
Updated
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.CompanyName)
</td>
<td>
@Html.DisplayFor(modelItem => item.TradingAs)
</td>
<td>
@Html.DisplayFor(modelItem => item.C_date)
</td>
<td>
@Html.DisplayFor(modelItem => item.C_updateDate)
</td>
<td>
@* @Html.ActionLink("View", "Edit", new { id = item.SalesContractId }) *@
<input type="button" value="View" id="btnFromIndexView" />
<td>
@* Add Button to print only if contract state is finalized *@
@if (item.IsFinal)
{
@Html.ActionLink("Print", "Print", new { id = item.SalesContractId })
<input type="button" value="Print" id="btnFromIndexPrint" />
}
</td>
</td>
</tr>
}
</table>
</body>
</html>
您是否試圖檢測服務器上的ID或通過某些客戶端腳本? –