我的 ViewUserControl 中的强类型类不起作用?
我的 viewuser 控件中出现错误:
无法加载类型“System.Web.Mvc.ViewUserControl”
我的视图页面在 RenderPartial 调用中传递 MyViewUserControllerUserList 类。
所以我正在做:
- action 创建它的强类型视图数据,它有一个属性,它是我的 userlist.ascx 期望的强类型类。
userlist.ascx:
Inherits="System.Web.Mvc.ViewUserControl<MyViewUserControllerUserList>"
我这样做正确吗?
更新
只是为了确保,我的强类型部分用户控件的代码是:
public class MyViewUserControllerUserList: ViewUserControl
{
}
I am getting an error in my viewuser control:
Could not load type 'System.Web.Mvc.ViewUserControl'
My viewpage passes the MyViewUserControllerUserList class in the RenderPartial call.
So I am doing:
- action creates its strongly typed view data, which has a property which is a strongly typed class that my userlist.ascx expects.
userlist.ascx:
Inherits="System.Web.Mvc.ViewUserControl<MyViewUserControllerUserList>"
Am I doing this correctly?
Update
Just to make sure, my code for my strongly typed partial user control is:
public class MyViewUserControllerUserList: ViewUserControl
{
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的语法看起来是正确的,但是您需要确保也包含名称空间。
然后您将像这样传递它
然后使用 Model 属性在部分内部访问它。
The syntax you have looks correct, however you need to make sure the namespace is incuded as well.
Then you would pass it in like this
Then access it inside the partial using the Model property.