在ASP MVC强类型的意见 [英] Strongly Typed Views in ASP MVC

查看:119
本文介绍了在ASP MVC强类型的意见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找通过斯科特Guthrie的MVC教程,它似乎像语法做强类型的观点已经改变,或者我做错了什么......

我的控制器code:

 返回查看(的currentUser);

在视图背后

code:

 公共部分类EditProfile:的ViewPage<使用者>

然而,在视图的前端code,如果我键入

 的ViewData。

我没有得到可用在我的User类的所有属性的智能感知,其实它看起来像在IEnumerable的可用方法。

列表

有人请把我从我的痛苦:)


解决方案

  ViewData.Model

你是如此接近:)

I have been looking through Scott Guthrie's MVC tutorials and it seems like the syntax for doing strongly typed views has changed, or I am doing something wrong...

My controller code:

return View(CurrentUser);

Code behind in the view:

    public partial class EditProfile : ViewPage<User>

Yet in the view's front end code if I type

ViewData.

I dont get any intellisense for the properties available in my User class at all, in fact it looks like a list of methods available in IEnumerable

Someone please put me out of my misery :)

解决方案

ViewData.Model

you were so close :)

这篇关于在ASP MVC强类型的意见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆