We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to invoke action by button click?

Platform: ASP.NET MVC |
Control: Button
Tags: general


You can invoke the controller action by Button using click event to your Syncfusion Button control. In the click event, you can use Url.Action method to invoke the particular action.


You can invoke the controller method by button click using the following code example. To include the Syncfusion components, add the necessary script and theme files in the <head> section as illustrated in the following code example.


<!--latest CDN for theme file-->
    <link href="http://cdn.syncfusion.com/js/web/flat-azure/ej.web.all-latest.min.css" rel="stylesheet" type="text/css" />
    <!--CDN for JQuery script file-->
    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js" type="text/javascript"></script>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/globalize/0.1.1/globalize.min.js"></script>
    <!--latest cdn for script file-->
    <script src="http://cdn.syncfusion.com/js/web/ej.web.all-latest.min.js"></script>
    <!--latest CDN for Unobtrusive JS file-->
    <script src="http://cdn.syncfusion.com/js/web/ej.unobtrusive-latest.min.js"></script>

You can create Button in CSHTML page as follows.


@Html.EJ().Button("Login").Text("Log in").Type(ButtonType.Button).ClientSideEvents(e=>e.Click("onclick"))

You can write the Url.Action for the Button click event in the script section as follows.


function onclick() {
        location.href = '@Url.Action("Index","Home")';

In the Url.Action you can specify the Controller name and the Action name. Finally, when you click on the Button, the click event is triggered and redirected to the corresponding method in a specified controller. Here, when you click on the Button it is redirected to the “Index” method in the “Home” controller.

2X faster development

The ultimate ASP.NET MVC UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile