Present a new UD-card after clicking a button

I have created a New-UDButton and for the on-click action I want a script to evaluate and then present a New-UDCard that is either red or green based on success or failure. I have been able to do this without issue in New-UDInputs/New-UDInputfield’s, but I can not get the on-click of a button to do the same thing… Maybe this is not possible?

  • Here is an example of the behavior I am trying to replicate with a button. “On-click, show a new UD-card that is green.”

    New-UDInputAction -Toast “User OTP: $Session:userOTP Session OTP: $Session:otpCode”
    if ($Session:userOTP -eq $Session:otpCode) {
    # $count = 0
    $Session:verified = true New-UDInputAction -Content @( New-UDCard -Title "($Session:user.data.username) was successfully authenticated. Proceed to enrollment…" -BackgroundColor ‘Green’
    )}

You’ll need take advantage of Set-UDElement or Add-UDElement to do this. Something like this:

New-UDElement -Tag 'div' -Id 'myControl'
New-UDButton -OnClick { Set-UDElement -Id 'myControl' -Content { New-UDCard -Title "Hello" - Text "Hello" }
1 Like

You rock man! Got it working.