简体   繁体   中英

Can I Create a Partial View with Controller

Using ASP.net MVC3 with C#

I want to create a partial view that uses a single database record so I have the View down fine but what controller would I create to actually create the LINQ query or do I need to do it in the View file?

The partial will display a random ad and be on every page on the site.

As M.Babcock says, you really should keep the logic out of the View and into the Controller (or Model if appropriate).

I would pass the resulted data to the View either through a Model , or it little data then just pass it through the ViewBag (or ViewData ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM