asp.net mvc - how to access input type=submit value in c# mvc controller -


i developing c# mvc application. have index action doubles , post action. in view, user able search project name or number (or other different options).

<tr>         <th>             find name:         </th>         <th>             @html.textbox("namesearchstring", viewbag.currentnamefilter string)         </th>         <th>             <input type="submit" value="search name" name="searchbutton" />         </th>     </tr>     <tr>         <td></td>     </tr>     <tr>         <td></td>     </tr>     <tr>         <th>             find project number:         </th>         <th>             @html.textbox("numbersearchstring", viewbag.currentnumberfilter string)         </th>         <th>             <input type="submit" value="search number" name="searchbynumber" />         </th>     </tr> 

is possible inspect value of "searchbutton" in controller via request.form?

in controller have:

// get: projects     [acceptverbs(httpverbs.get)]     public actionresult index(string sortorder, string currentnamefilter, string currentnumberfilter, string namesearchstring, string numbersearchstring, int? page,          string searchbutton, bool? activeprojectsonly = true)     { 

when click on "search name" button, in controller "searchbutton" string ="search name". expected, how come not able inspect using:

this.httpcontext.request.form["searchbutton"] 

this mvc level:

<dependentassembly>     <assemblyidentity name="system.web.mvc"  />     <bindingredirect oldversion="0.0.0.0-5.2.2.0" newversion="5.2.2.0" />   </dependentassembly> 

any appreciated.

[acceptverbs(httpverbs.get)]     public actionresult index(string sortorder, string currentnamefilter, string currentnumberfilter, string namesearchstring, string numbersearchstring, int? page,          string searchbutton, string searchbynumber, bool? activeprojectsonly = true)     { 

add searchbynumber controller parameters.

the controller parameters @ "name" tag when posting request.form. value of button, have reference it's name.

if form has multiple buttons, recommend using jquery or javascript set value of hidden field depending on button clicked , pass controller.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -