禁用@ Html.ActionLink,它是Razor视图中的btn btn-default,同时在布尔值比较中启用另一个@HtmlActionLink

时间:2017-01-20 20:46:38

标签: jquery asp.net-mvc-4 razor

我在Razor视图/ Bootstrap按钮中有以下@HtmlAction链接,它检查用户角色和布尔标志,以查看是否收到路由当前记录进行处理。解决方案是使用ASP.NET MVC4和C#。

<div class="panel-heading">
    <span>
        Production Submission Summary
        <span class="pull-right" style="margin-top:-8px">
            @if (User.IsInRole("Admin") && !ProdHeader.Received)
        {
                 @Html.ActionLink("Receive Shipment", "ReceiveSubmission", new { ProdHeaderId = Model.ProdHeader.Id }, new { @class = "btn btn-default" })
            }
        </span>
    </span>
</div>

我想添加另一个比较,它将检查名为PaymentReceived的布尔字段的状态,如果Paymentreceived为true,我想禁用PaymentReceived操作链接按钮并启用上面的Shipment received action链接。因此,应该禁用Shipmentreceived按钮,直到单击Paymentreceived按钮,然后应禁用PaymentReceived并激活shippingreceived按钮。我有如上所述的Paymentreceived设置的Action链接,但不确定在哪里检查布尔比较。它应该与ReceiveSubmission操作链接在同一个div中,还是单独使用,应该首先进行哪个比较? 非常感谢

HERE是完整的代码段。我可以在div中使用id并使其成为需要隐藏的那个吗?

@if (User.IsInRole("Admin") || User.IsInRole("Prod") && (!Model.ProdTypeHeader.ReceivedPayment))
            {

                @Html.ActionLink("Receive Payment", "ReceivePayment", new { prodTypeHeaderId = Model.ProdTypingHeader.Id}, new { @class = "btn btn-default" })
                @Html.ActionLink("Receive Shipment", "ReceivePayment", new { prodTypeHeaderId = Model.ProdTypingHeader.Id}, new { @class = "btn btn-default", disabled = "disabled" }) *@
            }



 @if (User.IsInRole("Admin") || User.IsInRole("Finance") && (!ModelProdTypeHeader.Received))
            {
                @Html.ActionLink("Receive Shipment", "ReceiveSubmission", new { prodTypeHeaderId = Model.ProdTypeHeader.Id}, new { @class = "btn btn-default" })
                @Html.ActionLink("Receive Payment", "ReceivePayment", new { prodTypeHeaderId = Model.ProdTypeHeader.Id}, new { @class = "btn btn-default" , disabled = "disabled"})
            }

1 个答案:

答案 0 :(得分:0)

如果您使用的是Bootstrap 4,而不是

ejs

尝试

new { @class = "btn btn-default" , disabled = "disabled"}

这对我有用。