[4.3.0] DotVVM.Framework.Compilation.DotvvmCompilationException: Content control must inherit from DotvvmControl, but DotVVM.Framework.Controls.ConfirmPostBackHandler doesn't

When I add this simple part to a repeater control, all is good, no compilation error:

<PostBack.Handlers>
    <dot:ConfirmPostBackHandler Message="Do you really want to submit the form?" />
</PostBack.Handlers>

But adding the same to a <dot:Button>, as shown in many examples, I get the error:
DotVVM.Framework.Compilation.DotvvmCompilationException: Content control must inherit from DotvvmControl, but DotVVM.Framework.Controls.ConfirmPostBackHandler doesn’t.

Do I miss something?!

Here is the full button control code I use in the page:

<dot:Button ButtonTagName="button" class="btn btn-icon p-0"
            title="{resource: SomeStringProperty}"
            IncludeInPage="{resource: SomeBooleanProperty}"
            Click="{command: SomeCommand()}">
    <ItemTemplate>
        <i class="flag flag-country-ch"></i>
    </ItemTemplate>
    <PostBack.Handlers>
        <dot:ConfirmPostBackHandler Message="Do you really want to submit the form?" />
    </PostBack.Handlers>
</dot:Button>

Best regards

Sorry, this is a bit confusing, but you just have to unwrap the <ItemTemplate>, and place PostBack.Handlers first.

Button has no ItemTemplate, you just place content inside it. DotVVM thus treats the <ItemTemplate> element as a classic HTML element (you’ll see it in the output). Since content must be after all element properties, the <PostBack.Handlers> is not treated as property either.

1 Like

Thanks a lot for your reply!

Now it works. :wink:

One thing I noticed in the browser console when I used this handler and clicked “Abort”:

I think this shouldn’t happen, because it’s the decision of the “user” to abort the confirm and not a real error of the framework doing something wrong.

And two other things I would like to mention:

  1. Your answer should be added to the docs because it’s essential on how to place the handlers within a button control along with the content.
  2. A prominent link to this forum is missing in the docs. It’s hard for “new” users to find where they can get additional help. :wink:

Best regards