views:

547

answers:

1

Hi,

in my MVC application I have a controller (ProjectController) which has an action (create). The create function accepts a projectEntity (custom 3d party datalayer component) as a parameter. The framework automatically binds the entered form values to the projectEntity object.

This is the create-function signature:

<AcceptVerbs(HttpVerbs.Post)> _
Function Create(<Bind(Exclude:="Id")> ByVal projectToCreate As BLL.projectEntity) As ActionResult
End Function

I have a field called 'requestDate' in the form. How can I specify the POST method so that it passes the projectToCreate object and the additional 'requestDate' from the form?

A: 

simply add your additional 1-1 parameters after your first (object) parameter...

 _
Function Create( ByVal projectToCreate As BLL.projectEntity, ByVal requestData As Nullable(Of Int)) As ActionResult
End Function

I usually will set types as input parameters to nullable. Only the first object will get mapped without other parameter names... if you have a signature with say (object A, object B) in your form, you can use name="someprop" which will get automapped to A.someprop, or you can use name="B.someprop" and it will automap, to the property within the name.

Tracker1