Product: PowerShell Universal
Version: 4.2.17
This is driving me nuts since I’ve done it successfully in a bunch of other places. i have this code that shows two calendars, then will enable a button, or disable it and show a red notice based on the dates selected
$today = get-date
New-UDGrid -container -content{
New-UDCard -Title "Start Date" -Content {
New-UDDatePicker -id "date_Start" -label "Start Date" -maximumdate $today -value $today -Variant static -views @("day") -Format "MM/dd/yyyy" -onchange {
Sync-UDElement -id "dyn_Dates"
}
}
New-UDCard -Title "End Date" -Content {
New-UDDatePicker -id "date_end" -label "End Date" -maximumdate $today -value $today -Variant static -views @("day") "MM/dd/yyyy" -onchange {
Sync-UDElement -id "dyn_Dates"
}
}
New-UDCard -Content {
new-uddynamic -id "dyn_Dates" -content {
$session:StartDate = (get-udelement -Id date_Start).value
$session:EndDate = (get-udelement -Id date_end).value
New-UDTypography -text "Start Date: $($session:StartDate.tostring("MM/dd/yyyy"))"
new-udhtml -markup "<br>"
New-UDTypography -text "End Date: $($session:EndDate.tostring("MM/dd/yyyy"))"
new-udhtml -markup "<br>"
if ($session:startdate -gt $session:EndDate){
new-udtypography "The start date must be before the end date" -Style @{color = "red"}
}
new-udhtml -markup "<br>"
new-udbutton -id "btnGetData" -text "Get Data" -onclick {
show-udtoast -message "clicked"
}
if ($session:startdate -gt $session:EndDate){
Show-UDToast -Message "gt"
Set-UDElement -id "btnGetData" -Properties @{
disabled = $true
}
}
else {
Show-UDToast -Message "lt"
Set-UDElement -id "btnGetData" -Properties @{
disabled = $false
}
}
}
}
}
The button doesn’t properly enable/disable based on the dates selected. Video below of it happening. The toast that pops up is either gt or lt depending on the dates selected. I was using that to make sure my If statement was working correctly, which it is.
I can’t seem to figure out why the button doesn’t work like it should.