# Problem with button condition "Enabled={true/false}"

**URL:** <https://forum.dotvvm.com/t/problem-with-button-condition-enabled-true-false/358>\
**Category:** Discussion in English\
**Created:** [April 29, 2026, 2:14pm UTC](https://forum.dotvvm.com/t/problem-with-button-condition-enabled-true-false/358 "2026-04-29T14:14:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dosmac](https://forum.dotvvm.com/letter_avatar_proxy/v4/letter/d/edb3f5/32.png) [@Dosmac](https://forum.dotvvm.com/u/Dosmac)\
**Post date:** [April 29, 2026, 2:14pm UTC](https://forum.dotvvm.com/t/problem-with-button-condition-enabled-true-false/358/1 "2026-04-29T14:14:47Z")

</div>

Hello, I am having trouble with disabling buttons conditionally:

I have this type of button:

```csharp
<dot:Button Enabled="{value: PJT.IsEnrichmentJobCreating}" ID="startEnrichmentBtn" ButtonTagName="button"
            class="btn btn-success fw-bold"
            Click="{command: ConfirmAndStartJob()}">
    <span Visible="{value: !PJT.IsEnrichmentJobCreating}">
        <i class="fa-solid fa-wand-magic-sparkles me-2"></i>Start Enrichment
    </span>
    <span Visible="{value: PJT.IsEnrichmentJobCreating}">
        <span class="spinner-border spinner-border-sm me-2"></span>Starting…
    </span>
</dot:Button>

```

and I have a javascript event to actually make the button disabled while the viewmodel is running its function:

```javascript
dotvvm.events.beforePostback.subscribe(function (sender) {
    var id = sender.sender ? sender.sender.id : null;
    if (id === 'startEnrichmentBtn') dotvvm.viewModels.root.viewModel.PJT().IsEnrichmentJobCreating(true);
});

```

But instead of actually working, I get this error.

 ![image](https://forum.dotvvm.com/uploads/default/original/1X/bbfd458e6ecbaac9a739cc2bb266635ac3d21eb2.png)

So I’m wondering what is the proper way to disable a button while a function is running on the backend?  
Thanks for any answers, this is driving me crazy 😛

---

<div class="post-metadata">

**Author:** ![exyi](https://forum.dotvvm.com/user_avatar/forum.dotvvm.com/exyi/32/9_2.png) [@exyi](https://forum.dotvvm.com/u/exyi)\
**Post date:** [April 29, 2026, 6:17pm UTC](https://forum.dotvvm.com/t/problem-with-button-condition-enabled-true-false/358/2 "2026-04-29T18:17:51Z")

</div>

Hi!

Sorry about this, it’s a weird behavior which disables commands on disabled buttons. Since you disable the button via the view model before DotVVM serializes it and sends it to server, the button will also be disabled on the server, your command binding will be ignored and you get the “command not found” error.

I think in your case, you can actually use `_page.IsPostbackRunning` in the Enabled binding instead of your own property (which is always false on server even when we are in a postback…).

In more general case, you can prefix the binding with `_page.EvaluatingOnServer ||` to keep the button enabled enabled server-side, while doing whatever else client-side

---

<div class="post-metadata">

**Author:** ![Dosmac](https://forum.dotvvm.com/letter_avatar_proxy/v4/letter/d/edb3f5/32.png) [@Dosmac](https://forum.dotvvm.com/u/Dosmac)\
**Post date:** [April 30, 2026, 7:31am UTC](https://forum.dotvvm.com/t/problem-with-button-condition-enabled-true-false/358/3 "2026-04-30T07:31:57Z")

</div>

Hello!

I didn’t even know this existed until now but I will be using it from now on.

Thanks for the reply!
