I have some data in ViewData.Model, and in my views I want to write a partial view and to pass their current model I have in my page.
How I can pass their current ViewData.Model and render them through the location of partials?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Create your partial view something like:
Then in your view use:
If you do not want a strongly typed partial view remove the
@model YourModelTypefrom the top of the partial view and it will default to adynamictype.Update
The default view engine will search for partial views in the same folder as the view calling the partial and then in the ~/Views/Shared folder. If your partial is located in a different folder then you need to use the full path. Note the use of
~/in the path below.