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

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

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:

@Html.EJ().Button("ok").Text("OK").Type(ButtonType.Submit).Size(ButtonSize.Medium)

3 Replies

DL Deepa Loganathan Syncfusion Team May 26, 2016 08:42 AM UTC

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")); 
    } 
    <div> 
        @using (@Html.BeginForm()) 
        { 
            @Html.EJ().Button("submit_button").Text("Submit").ShowRoundedCorner(true).HtmlAttributes(btnAttributes).Type(ButtonType.Submit) 
        } 
    </div> 
 

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



TF Tom Frajer May 26, 2016 11:51 AM UTC

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)


DL Deepa Loganathan Syncfusion Team May 27, 2016 05:44 AM UTC

 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.     
     
Regards,      
Deepa L.    


Loader.
Live Chat Icon For mobile
Up arrow icon