how to create a button in Sitecore SXA which would call a controller action or a rest Api ?
would it be through javascript or is there an ootb feature in SXA , where i could get the user and item context ?
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 communityThis 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.