How to create a button to link to other pages?

With UD v2.3.2 I used the code below to create buttons that link to other dashboard pages. Somewhere along the line Attributes appears to have been removed. How do make a button link now? Do I need to use -OnClick somehow?

$Button =  New-UDButton -Text 'Cancel' 
$Button.Attributes.href = "../MainMenu"
$Button

UdButton Attributes are not working since 2.5.2
A ticket was opened a few months back related to that (still open).

Meanwhile, here are two solutions for you to produce the same result.

This way, which work perfectly fine.
New-UDButton -Text 'Cancel' -OnClick { Invoke-UDRedirect -Url '../MainMenu' }

And the New-UDHtml method, which always is a good workaround for anything when something break (although since the first sample work, you don’t really need that second one).
New-UDHtml -Markup '<a href="../MainMenu" class="btn ud-button">Cancel</a>'

Regarding the attribures breaking change:

2 Likes