c# - Submitting a form using a second button to call another method -
so have form:
@using (html.beginform("sendmailasacompany", "contract", formmethod.post, new { id = "cvr" })) { <input type="hidden" value=@model name="studentid" /> <input type="hidden" value=@model.project.userid name="companyid" /> <input type="hidden" value=@model.applicationid name="applicationid"/> <input type="text" name="companycvr" placeholder="indsæt cvr-nr." required/> }
then @ bottom of page have submit button:
<button form="cvr" class="btn btn-success">submit</button>
i want add second button submit same data call method instead of "sendmailasacompany". there way modify button/form accommodate change?
yes, can change html form attribute dynamically jqyery/javascript
this 1st button:
<button form="cvr" class="btn btn-success">submit</button>
this other 1 submit data on action method:
<input type="button" id="btnsave" onclick="submitform()" value="save"/> function submitform() { $("#cvr").attr("action", "your controller/your new action method"); $('#cvr').submit(); }
i hope helpful! if not clear here plz let me know.
Comments
Post a Comment