I recommend not to use input of type submit. Instead try to use html anchor (link) - or Html.ActionLink in MVC to reload the page or redirect somewhere.
Similar question posted here: Cancel button in form
UPDATE 1 - according to @sam360 comment
You can try to put MultiButtonAtribute on action method which should handle the cancel button request:
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class MultiButtonAttribute : ActionNameSelectorAttribute
{
public MultiButtonAttribute(string matchFormKey) : this(matchFormKey, null) {
}
public MultiButtonAttribute(string matchFormKey, string matchFormValue) {
this.MatchFormKey = matchFormKey;
this.MatchFormValue = matchFormValue;
}
public string MatchFormKey { get; set; }
public string MatchFormValue { get; set; }
public override bool IsValidName(ControllerContext controllerContext, string actionName, MethodInfo methodInfo)
{
string value = controllerContext.HttpContext.Request[MatchFormKey];
return value != null && (value == MatchFormValue || MatchFormValue == null);
}
}
If the name of the button ("cancel") will be matched in the request, the cancel action mathed would handle the request.
[HttpPost]
[MultiButton("cancel")]
public ActionResult CancelAction(MyModel model)
{
// ... update the model (e.g. remove the last item from list and return the view with updated model
}
And in the form you will have:
<input type="submit" name="cancel" value="Remove Item" class="cancel" />
But if I understand it well. You want to dynamically add/delete inputs on some form. You should consider doing it client side using javascript or jQuery functions to save some server requests (but maybe it is not an option for you if you want to support clients without javascript enabled).