javascript - specify which button triggered a form submission into an ASP.NET app -


into asp.net mvc aplication, use form several submit buttons. can route them correct controller action way:

@using (html.beginform("actionname", "controllername", formmethod.post)) ... <input type="submit" name="submit_button" value="action1"  /> <input type="submit" name="submit_button" value="action2"  />     

then controller:

 public actionresult validate_form(..., string submit_button)         { switch submit_button {     ...    } } 

this works perfectly.

now d include js action before submitting form. change input submit input button , add onclick event way:

  <input type="button" name="submit_button" value="action1" class="col-md-2" onclick="jsaction()" /> 

js function:

function jsaction(){ ...my stuff document.getelementbyid('formname').submit(); } 

and then, when controller validate_form method run, looses submit_button argument (null value). can explain me why? how can solve issue?

thx in advance.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -