开发者

ActionLink only if a certain condition is met

开发者 https://www.devze.com 2023-02-27 07:59 出处:网络
If s = \"N/A\" then I don\'t want to use the ActionLink.In other words, if the inventory item is not currently being used on a project, then don\'t provide the link (just show N/A instead).Also, how d

If s = "N/A" then I don't want to use the ActionLink. In other words, if the inventory item is not currently being used on a project, then don't provide the link (just show N/A instead). Also, how do I send the link to Projects/Details? Right now, it will go to "Nails/Projects/Details" instead, because I'm using the NailsController class.

            <td class="table-normal-data">
            <%  Dim l As Integer = InStr(item.CurrentPro开发者_运维技巧ject, " [")
                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>


I'm much more familiar with MVC3/Razor and C#, but I often do something like this in my views:

@if( Model.Flag )
{
    <span>n/a</span>
}
else
{
    @Html.ActionLink(....
}

Basically, you output different stuff through the view depending on the state of the model.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号