Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Relation between controller,view and model in asp.net mvc

Relation between controller,view and model in asp.net mvc

Scheduled Pinned Locked Moved ASP.NET
asp-netcsharpcomarchitecturehelp
6 Posts 5 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tridip Bhattacharjee
    wrote on last edited by
    #1

    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

    D J A 3 Replies Last reply
    0
    • T Tridip Bhattacharjee

      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

      D Offline
      D Offline
      deepankarbhatnagar
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • D deepankarbhatnagar

        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

        T Offline
        T Offline
        Tridip Bhattacharjee
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • T Tridip Bhattacharjee

          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

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          It is all explained at https://msdn.microsoft.com/en-us/library/dd381412(v=vs.108).aspx[^].

          1 Reply Last reply
          0
          • T Tridip Bhattacharjee

            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

            J Offline
            J Offline
            Joshua Omundson
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • T Tridip Bhattacharjee

              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

              A Offline
              A Offline
              Anurag Gandhi
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups