Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
基本上,我有一个页面引用了作为模板“窗口”容器的布局页面。我想知道ViewBag将信息从内页传递到布局页面的最佳(非)方法是什么?
ViewBag
将模板绑定到视图模型。最好有一个基本视图模型(用于父视图),然后您的子视图模型将实现父视图模型。
public class ParentViewModel { public string SomeSharedField { get; set; } } public class ChildViewModel : ParentViewModel { public string SomeFieldJustForChild { get; set; } }