I am trying to create a simple contact form. Here is my model:
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
Here is my View:
@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
And, here is my controller:
Function Contact() As ActionResult
Return View("", "_FinalSubPageLayout", "")
End Function
The error I get is:
The model item passed into the dictionary is of type ‘System.String’,
but this dictionary requires a model item of type ‘MyBlog.Contact’.
What can I do to resolve this error? Thank you.
I’m not sure about that first
"", you may need to specify the actual name or pass Nothing or something.