我正在嘗試創建一個簡單的聯繫人窗體。這裏是我的模型:無法在MVC中創建聯繫人窗體3
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'類型的模型項目。
我該如何解決這個錯誤?謝謝。
謝謝,但它不是一個變量。它是一個佈局名稱'_FinalSubPageLayout.vbhtml'。你可以將它替換爲View(),它將渲染具有相同錯誤的視圖(不在佈局中)。 – user1477388
對,我必須查看過載情況。編輯... –
真的很好趕,夥計們。我沒有意識到我必須在那裏發送模型。 – user1477388