在布局视图中绑定下拉列表
我是一名 ASP.NET WebForms 程序员,对 ASP.NET MVC3 非常陌生。我在 _Layout 视图中有一个下拉列表,需要在所有页面上填充它。我不想在每个控制器中调用一些代码,因此我将下拉列表移动到部分视图中,并使用 @Html.Partial("_DropDownList") 将其放在页面上。我需要为此视图创建一个控制器吗?如果是这样,我如何指定它需要使用的控件?
I am an ASP.NET WebForms programmer and I'm very new to ASP.NET MVC3. I've got a dropdownlist inside the _Layout view and it needs to be populated on all the pages. I don't want to have to call some code inside every Controller, so I've moved the dropdownlist in a Partial View and put it on the page using @Html.Partial("_DropDownList"). Do I need to create a controller for this View? If so, how can I specify control it needs to use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想查看 @Html.Action 和 @Html。渲染操作。它们允许您引用控制器操作并返回输出。
You might want to look at @Html.Action and @Html.RenderAction. They allow you to reference a controller action and return the output.