asp.net - Is there a way to send a parameter though a button? -
i have link witch yo change button, link passes though parameter , looks follows:
@html.actionlink("view", "print", new { id = item.salescontractid }) i want replace button parameter { id = item.salescontractid }
my button looks follows:
<input type="button" value="print" id="btnfromindexprint" /> could show me how ca go doing this?
this how page looks can see i'm trying achive:
@model ienumerable<contract.models.tbsalescontract> <!doctype html> <html> <head> <title>index</title> </head> <body> <p> @html.actionlink("create new", "edit") </p> <table> <tr> <th> company </th> <th> trading </th> <th> created </th> <th> updated </th> <th></th> </tr> @foreach (var item in model) { <tr> <td> @html.displayfor(modelitem => item.companyname) </td> <td> @html.displayfor(modelitem => item.tradingas) </td> <td> @html.displayfor(modelitem => item.c_date) </td> <td> @html.displayfor(modelitem => item.c_updatedate) </td> <td> @* @html.actionlink("view", "edit", new { id = item.salescontractid }) *@ <input type="button" value="view" id="btnfromindexview" /> <td> @* add button print if contract state finalized *@ @if (item.isfinal) { @html.actionlink("print", "print", new { id = item.salescontractid }) <input type="button" value="print" id="btnfromindexprint" /> } </td> </td> </tr> } </table> </body> </html>
if have @ source code actionlink generates, see regular hyperlink. id parameter appended url.
so, replacing hyperlink button won't same.
in asp.net mvc data can send server in several ways. 1 actionlink uses append data url. routing mechanism map specific properties on action method.
another way send data use html form. form can have submit button send form data server.
asp.net mvc check following sources when searching possible values action method:
- previously bound action parameters, when action child action
- form fields (request.form)
- the property values in json request body (request.inputstream), when request ajax request
- route data (routedata.values)
- querystring parameters (request.querystring)
- posted files (request.files)
Comments
Post a Comment