【发布时间】:2012-10-02 14:07:02
【问题描述】:
我正在尝试创建一个简单的联系表单。这是我的模型:
Imports System.Data.Entity
Imports System.ComponentModel.DataAnnotations
Public Class Contact
Public Property Name() As String
Public Property Title() As String
Public Property Company() As String
Public Property CompanyAddress() As String
Public Property PhoneNumber() As String
Public Property NumberOfEmployees() As String
Public Property EmailAddress() As String
Public Property Subject() As String
Public Property Message() As String
End Class
这是我的观点:
@ModelType MyBlog.Contact
@Code
ViewData("Title") = ViewBag.Title
End Code
@Using Html.BeginForm()
@Html.LabelFor(Function(model) model.EmailAddress)
@Html.EditorFor(Function(model) model.EmailAddress)
@Html.ValidationMessageFor(Function(model) model.EmailAddress)
@<input type="submit" value="Send" />
End Using
还有,这是我的控制器:
Function Contact() As ActionResult
Return View("", "_FinalSubPageLayout", "")
End Function
我得到的错误是:
传入字典的模型项是'System.String'类型, 但是这本词典需要一个“MyBlog.Contact”类型的模型项。
我可以做些什么来解决这个错误?谢谢。
【问题讨论】:
标签: vb.net asp.net-mvc-3 razor