This is a migrated thread and some comments may be shown as answers.

How can I get a handle on which button fired "submit" from MVC controller?

2 Answers 654 Views
ButtonGroup (Mobile)
This is a migrated thread and some comments may be shown as answers.
Warner
Top achievements
Rank 2
Warner asked on 01 May 2015, 02:40 AM

Simple use case; a pretty common one I would assume:

I have more than one kendo button displayed within an MVC view.  When one of the buttons fires the "submit" event, I want to be able to grab a handle on which button fired the submit from within my controller.  I had assumed that you could assign "button" to the name attribute and then determine through the button's "value" property which button fired the event.

The controller signature would look like this: 

[HttpPost]

public ActionResult(string button) { determine course of action based on button's value property...}

I'm actually taken back at the fact that one of the most fundamental uses of the input button type is simply not given any means to do this simply. Of course, I could be blind and missing something, but I've searched forums and Telerik documentation and found little if anything on performing this basic task.

 

Thanks!

 


    

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 05 May 2015, 07:42 AM
Hello,

Using input type submit or button element is not supported. The scenario can be implemented by using the select event to set the value to a hidden input and submit the form e.g.
@using (Html.BeginForm())
{
    ...
    <input type="hidden" id="button" name="button"/>
}
function onSelect(e) {
    var text = this.current().text();
    $("#button").val(text);
    $("form").submit();
}


Regards,
Daniel
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Warner
Top achievements
Rank 2
answered on 05 May 2015, 03:55 PM

Thank you!  That's pretty much the work-around I used.

Somewhere in the future, you may want this functionality incorporated into the actual control. After all, it is a common use case for buttons.

Tags
ButtonGroup (Mobile)
Asked by
Warner
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Warner
Top achievements
Rank 2
Share this question
or