May 06, 2012, 10:33 AM
[Razor] Populating form values from controller
Hi there,
I'm just having some issues populating a form with data that I must retrieve from the controller. There are many examples in webforms but I'm just wondering what the best way to do this in Razor views would be. Basically I have a details view which receives an ID parameter into its controller method and retrieves the necessary data but now I'm not sure what to do with it. Must I create a store for the form and some sort of listener or can I simply set up the relevant model object for my form view (as you do in normal MVC) and then just set the text field values (for instance) as Model.Fieldname etc.? It seems like there are several ways to achieve the same thing and I'm not sure about the advantages/disadvantages of the various approaches?
I'm just having some issues populating a form with data that I must retrieve from the controller. There are many examples in webforms but I'm just wondering what the best way to do this in Razor views would be. Basically I have a details view which receives an ID parameter into its controller method and retrieves the necessary data but now I'm not sure what to do with it. Must I create a store for the form and some sort of listener or can I simply set up the relevant model object for my form view (as you do in normal MVC) and then just set the text field values (for instance) as Model.Fieldname etc.? It seems like there are several ways to achieve the same thing and I'm not sure about the advantages/disadvantages of the various approaches?