how to create a button in Sitecore SXA which would call a controller action or a rest Api ?
Sitecore Stack Exchange is a question and answer site for developers and end users of the Sitecore CMS and multichannel marketing software. It only takes a minute to sign up.Sign up to join this community
This question is not SXA specific question. It's Sitecore MVC question.
You can see how it's done for Login, Logout renderings. Both of them use
Html.BeginForm() helper. The disadvantage of this is that page will reload once you click submit button. At the same time, it is good because there is security protection (
@Html.AntiForgeryToken()) against cross-site request forgery.
Another way would be JS call (AJAX Request) but there is no snippet for that in the SXA code.
You should review the answers for those keywords: "call controller action sitecore mvc"
I am sure you will find something.