razor - ASP.Net MVC 4 Form with 2 submit buttons/actions -
i have form in asp.net , razor.
i need have 2 ways of submitting said form: 1 goes through edit action, , goes through validate action.
how should go doing this?
i don't mind using javascript this.
edit:
using custom attribute error.
the current request action 'resultados' on controller type 'inspecoescontroller' ambiguous between following action methods: system.web.mvc.actionresult validar(system.collections.generic.icollection
1[waveform.iep.intus.server.web.viewmodels.resultadoviewmodel]) on type waveform.iep.intus.server.web.controllers.inspecoescontroller system.web.mvc.actionresult resultados(system.collections.generic.icollection1[waveform.iep.intus.server.web.viewmodels.resultadoviewmodel]) on type waveform.iep.intus.server.web.controllers.inspecoescontroller
that's have in our applications:
attribute
public class httpparamactionattribute : actionnameselectorattribute { public override bool isvalidname(controllercontext controllercontext, string actionname, methodinfo methodinfo) { if (actionname.equals(methodinfo.name, stringcomparison.invariantcultureignorecase)) return true; var request = controllercontext.requestcontext.httpcontext.request; return request[methodinfo.name] != null; } } actions decorated it:
[httpparamaction] public actionresult save(mymodel model) { // ... } [httpparamaction] public actionresult publish(mymodel model) { // ... } html/razor
@using (@html.beginform()) { <!-- form content here --> <input type="submit" name="save" value="save" /> <input type="submit" name="publish" value="publish" /> } name attribute of submit button should match action/method name
this way not have hard-code urls in javascript
Comments
Post a Comment