What is difference between partial view and strongly view
What is the difference between partial view and strongly view.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Nilesh JadavPosted Aug 26, 2016, 3:20 AM
This answer might help you :
A partial view is nothing more than a "piece" of Html that you can keep in a separate file that you can reuse in other views. Sort of like UserControls in ASP.NET WebForms.
A Strongly Typed view means it has a ViewModel associated to it that the controller is passing to it and all the elements in that View can use those ViewModel properties
You can have strongly typed partials as well. Meaning that piece of Html needs specific data so you type it to a certain ViewModel
Here is an example of a Strongly Typed View
A view that is not strongly typed does not have a
@model SomeViewModellineHere's an example of a controller action that renders a normal view without a ViewModel
Here's one that renders a strongly typed View
And the view makes use of that ViewModel by having the
@model SomeViewModelat the top of the file.So now that the view has a ViewModel I can display elements that are bound to the ViewModel like
So any data entered into those fields are bound to the ViewModel. When the user clicks the submit button, those entered values get sent back to the server.
As I said before, partial view is a reusable piece of Html. So in that same view I can add in my partial. Let's say I have a partial view that contains a standard bit of Html that I want to reuse all over my site, like a Footer
I can create a .cshtml file and put this inside it
And then include it on any View, doesn't matter if it's strongly typed or not, it's just reusable Html
Hope that might helps you !