Relation between controller,view and model in asp.net mvc
-
please see the below image just clicking on it https://i-msdn.sec.s-msft.com/dynimg/IC263184.png[^] i often seen the below picture is used to show the relation between controller,view and model in asp.net mvc project. i do not know much about asp.net MVC but still i guess first request is process by controller and controller gets data from model and push that data to view by controller just to populate the view. if anyone see the below image then probably notice that view can interact with model but that is not true. why people use the image for showing the relationship for mvc. if the above image is right so anyone please tell me how view can pass any info to model directly with taking any help from controller. please explain what the image is trying to say in details. thanks
tbhattacharjee
-
please see the below image just clicking on it https://i-msdn.sec.s-msft.com/dynimg/IC263184.png[^] i often seen the below picture is used to show the relation between controller,view and model in asp.net mvc project. i do not know much about asp.net MVC but still i guess first request is process by controller and controller gets data from model and push that data to view by controller just to populate the view. if anyone see the below image then probably notice that view can interact with model but that is not true. why people use the image for showing the relationship for mvc. if the above image is right so anyone please tell me how view can pass any info to model directly with taking any help from controller. please explain what the image is trying to say in details. thanks
tbhattacharjee
The model–view–controller design defines the interactions between them. A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document). A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. In some cases an MVC implementation may instead be 'passive' and other components must poll the model for updates rather than being notified. A view requests information from the model that it uses to generate an output representation to the user.
hi
-
The model–view–controller design defines the interactions between them. A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document). A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. In some cases an MVC implementation may instead be 'passive' and other components must poll the model for updates rather than being notified. A view requests information from the model that it uses to generate an output representation to the user.
hi
i just give the image and try to know how view and model can interact with each other without taking help from controller? as far as i know a view or model can not directly talk to each other rather they always need to go via controller. am i right ? need discussion on this. thanks
tbhattacharjee
-
i just give the image and try to know how view and model can interact with each other without taking help from controller? as far as i know a view or model can not directly talk to each other rather they always need to go via controller. am i right ? need discussion on this. thanks
tbhattacharjee
-
please see the below image just clicking on it https://i-msdn.sec.s-msft.com/dynimg/IC263184.png[^] i often seen the below picture is used to show the relation between controller,view and model in asp.net mvc project. i do not know much about asp.net MVC but still i guess first request is process by controller and controller gets data from model and push that data to view by controller just to populate the view. if anyone see the below image then probably notice that view can interact with model but that is not true. why people use the image for showing the relationship for mvc. if the above image is right so anyone please tell me how view can pass any info to model directly with taking any help from controller. please explain what the image is trying to say in details. thanks
tbhattacharjee
The view can interact with the model through a feature called model binding. So for example, you have a view that will post back to a controller. If the view is tied to a model then the MVC Framework will loop through all of the form elements and match them up with the properties in the Model, and then pass the filled model over to the controller. I would recommend going through a few tutorials over at www.asp.net[^] so you get a better understanding from a hands on approach.
-
please see the below image just clicking on it https://i-msdn.sec.s-msft.com/dynimg/IC263184.png[^] i often seen the below picture is used to show the relation between controller,view and model in asp.net mvc project. i do not know much about asp.net MVC but still i guess first request is process by controller and controller gets data from model and push that data to view by controller just to populate the view. if anyone see the below image then probably notice that view can interact with model but that is not true. why people use the image for showing the relationship for mvc. if the above image is right so anyone please tell me how view can pass any info to model directly with taking any help from controller. please explain what the image is trying to say in details. thanks
tbhattacharjee
Hi, I think you are confused with arrow point towards model. Don't worry. To understand this, you should know a bit about Design/UML/Diagram. View -> Model means that View can have instance of Model OR View knows about Model. This is true. In MVC pattern, we define model instance in View and Model is passed from controller to View. View can access Model while executing it. Similarly, Controller -> Model means that Controller has instance of Model OR Controller knows Model. Controller -> View means that Controller has instance of View. Anyways, this is very high level understanding and in my opinion the diagram is fundamentally correct.
Life is a computer program and everyone is the programmer of his own life.