我正在尝试创建一个简单的联系表格。这是我的模型:
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”类型的模型项。
我能做些什么来解决这个错误?谢谢你。