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.
Unfortunately, activation email could not send to your email. Please try again.

how to make a button with @ Html.ActionLink?

Thread ID:

Created:

Updated:

Platform:

Replies:

117267 Sep 19,2014 07:08 AM Sep 24,2014 12:08 AM ASP.NET MVC 3
loading
Tags: Button
ezequie da silva daniel
Asked On September 19, 2014 07:08 AM

hello, 

I've read the manual several times, I searched in google, Syncfusion the site and could not make a Html.ActionLink work with the button, calling the controller can give me an example?

Saranya Sivakumar [Syncfusion]
Replied On September 23, 2014 05:25 AM

Hi Ezequie,

We would like to let you know that, we cannot directly make the Html.ActionLink to work using button. Since Html.ActionLink returns the anchor tag. So we have to customize CSS style to the anchor tag to look like a button. Else we have to use “@Url.Action(“actionName”,”controllerName”)” in order to redirect to the view page. Both Html.ActionLink and Url.Action will works similarly. Hence we can use Url.Action instead of Html.ActionLink. For your convenience we have prepared the sample based on your requirement. Please download the same in the following location.

Sample Location: Sample

In the above sample we have created the button and binded the click event in the script section. In the click event we have given the Url.Action to redirect to the view page. Please find the following code snippet for more reference.

We have created the button in CSHTML page as follows.

[CSHTML]

<button id="button1">

button>

 

We have initialized the Button and Url.Action in the script section as follows.

[Javascript]

<script type="text/javascript">

    $(document).ready(function () {

        $("#button1").ejButton({

            "click": "onclick",

            text: "Click Here"

        });

    });

    function onclick() {

        document.location = '@Url.Action("Index","Home")';

    }

script>

Please let us know if you have further concern.

Regards,

Saranya.S


ezequie da silva daniel
Replied On September 23, 2014 08:05 AM

Ok, Thanks, solved! 

Regards,

Ezequiel

Saranya Sivakumar [Syncfusion]
Replied On September 24, 2014 12:08 AM

Hi Ezequie,

Thanks for your update.

Please get back to us if you have further concern, we will be happy to help you out.

Regards,

Saranya.S


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;