0

I have the following @HtmlAction link in Razor view/Bootstrap button which checks a user role and a Boolean flag to see if a routed current record is received for processing. The solution is using ASP.NET MVC4 and 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>

I want to add another comparison that will check the status of a Boolean field called PaymentReceived and if Paymentreceived is true I want to disable the PaymentReceived action link button and enable Shipment received action link above. So the Shipmentreceived button should be disabled until the Paymentreceived button is clicked and then the PaymentReceived should be disabled and the shipmentreceived button should be activated. I have the Action link for the Paymentreceived set up like above but not sure where to check the Boolean comparison. Should it be in the same div as the ReceiveSubmission action link or by itself and which comparison should be done first? Thanks so much

HERE is the full code segment. Can I just use a id in a div and make the one that needs to be hidden toggle ?

@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"})
            }
RickZler
  • 33
  • 8
  • This may help you - http://stackoverflow.com/questions/9846845/mvc3-how-to-disable-enable-actionlink – James P Jan 23 '17 at 13:52
  • I saw that awhile ago. The problem I'm having is the way I'm doing it its showing each button twice. One for the disabled state and one for the enable state. So I'm just checking the Boolean condition and running the action results changing my status and then disabling the button that sent me to the action result and right after enable the shipment received button. But it's grouping the buttons instead of overwriting them so you get 4 buttons. Payment received enabled Shipment received disabled Payment received disabled Shipment received enabled all in a row. – RickZler Jan 24 '17 at 02:21
  • Ok, please can you add full code or put it on github? – James P Jan 24 '17 at 11:37
  • I added the rest of the code without the html class and span tags. I described the situation in detail above. Would I be better of just putting the 2nd group of buttons in their own div with a id and just use a bootstrap toggle to hide the right buttons at the right time. Cause right now I getting both states of both buttons. – RickZler Jan 25 '17 at 00:58

1 Answers1

0

If you are using Bootstrap 4, instead of

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

try

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

This worked for me.