asp.net mvc - Map view Html controls to specific action object MVC -
i have action
public actionresult index(int id,int name, someobject object) { //somecode }
and someobject class
public class someobject { public int id {get; set;} public int name {get; set;} }
my view
@using (html.beginform()) { @html.textbox("id", "") @html.textbox("name", "") @html.textbox("object_id", "") @html.textbox("object_name", "") <button class="btn-default" type="submit">go</button> }
every time submit got object.id , object.name
parameters of index
action have same values of id , name
, can them correctly?
note: don't want rename prameters
you should update view :
@using (html.beginform()) { @html.textbox("id", "") @html.textbox("name", "") @html.textbox("object.id", "") @html.textbox("object.name", "") <button class="btn-default" type="submit">go</button> }
using "." instead of "_" , try parameter name "object" :)
Comments
Post a Comment