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.

Set button formaction attribute for routing multiple buttons to different actions in controller

Thread ID:





124225 May 25,2016 09:20 AM May 27,2016 01:44 AM ASP.NET MVC 3
Tags: Button
Tom Frajer
Asked On May 25, 2016 09:20 AM

Hi I want to use HTML5 atribute formaction to route multiple buttons to different actions in my controller. 
In HTML it is like this:

<input type="submit" name="ok" value="OK" formaction="/Controller/Save" formmethod="post" />
<input type="submit" name="back" value="Back" formaction="/Controller/Back" formmethod="post" />

My question is, how can I set formaction attribute on this Syncfusion button:


Deepa Loganathan [Syncfusion]
Replied On May 26, 2016 04:42 AM

Hi Tom,    
Thanks for contacting Syncfusion support.    
You can achieve this requirement by using “HtmlAttributes” API in Button EJHelper.   
Please refer the below code example:   
        Dictionary<string, object> btnAttributes = new Dictionary<string, object>(); 
        btnAttributes.Add("formaction", @Url.Action("Change", "Form")); 
        @using (@Html.BeginForm()) 

Please let us know if you need any further assistance.   
Deepa L. 

Tom Frajer
Replied On May 26, 2016 07:51 AM

Perfect! Thank you :)

I just simplified it into this:

@Html.EJ().Button("call_yes").Text("Call YES").HtmlAttributes(new Dictionary<string, object> { { "formaction", "/Ticking/TickingCallYes" } }).Type(ButtonType.Submit).Size(ButtonSize.Medium)

Deepa Loganathan [Syncfusion]
Replied On May 27, 2016 01:44 AM

 Hi Tom,    
Thanks for the update.     
We are glad to know that the given solution has met your requirement.     
Please let us know if you need any further assistance.     
Deepa L.    


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.