1
如果s =「不適用」,那麼我不想使用動作鏈接。換句話說,如果庫存項目當前未在項目中使用,則不要提供鏈接(只需顯示N/A)。另外,如何將鏈接發送到Projects/Details?現在,它會轉到「Nails/Projects/Details」,因爲我使用的是NailsController類。僅當滿足一定條件時動作鏈接
<td class="table-normal-data">
<% Dim l As Integer = InStr(item.CurrentProject, " [")
Dim s As String = item.CurrentProject
Dim projectID As String = ""
If l > 0 Then
s = Mid(item.CurrentProject, 1, l - 1)
projectID = Mid(item.CurrentProject, l + 2, Len(item.CurrentProject) - l - 2)
Else
s = ""
End If
%>
<%: Html.ActionLink(s, "Projects/Details", New With {.id = projectID}) %>
</td>
我修改了ActionLink,將其更改爲:Html.ActionLink(s,「Details」,「Projects」,New With {.id = projectID},「」) – user713723 2011-04-18 16:58:10
另外,如果s =「N/A」,我已經添加了projectID = 0,所以「N/A」仍然有一個鏈接(對我而言是不受歡迎的),但是項目ID將爲0.因此,單擊該鏈接將產生一個頁面「Project Not Found」 。再次,我寧願沒有「N/A」的鏈接,但我認爲沒有辦法在<% %>代碼標籤中嵌入Html.ActionLink。 – user713723 2011-04-18 17:01:51