MVC PartialView in multiple Views with different models

后端 未结 4 1965
南方客
南方客 2021-01-27 02:58

This may be a silly question and is more of a question about how to do something rather than an actual coding issue.

I want to have a partial view which contains a searc

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-27 03:44

    So each partial view is going to be directly tied to a model. If you're looking to have different information from different models in the same view, your best bet would be the concept of a modal. In terms of having search and search result partial views rendering together on the same view. Make sure you are accounting for where you are saying how you are using the model (i.e. @model [model name here] or @model IEnumberable<[model name here]> IF you are enumerating over your results like what would be likely for displaying a list of search results from a database; try using the a separate viewmodel. This will allow you to change how you are interacting with specific tables/columns indiviudally (i.e. if you are enumerating through them)

提交回复
热议问题