Hello,
I have this sample ASP.NET MVC 2.0 view in C#, bound to a strongly typed model that has a first name, last name, and email:
<div>
First: <%= Html.TextBoxFor(i => i.FirstName) %>
<%= Html.ValidationMessageFor(i => i.FirstName, "*") %>
</div>
<div>
Last: <%= Html.TextBoxFor(i => i.LastName) %>
<%= Html.ValidationMessageFor(i => i.LastName, "*")%>
</div>
<div>
Email: <%= Html.TextBoxFor(i => i.Email) %>
<%= Html.ValidationMessageFor(i => i.Email, "*")%>
</div>
I converted it to VB.NET, seeing the appropriate constructs in VB.NET 10, as:
<div>
First: <%= Html.TextBoxFor(Function(i) i.FirstName) %>
<%= Html.ValidationMessageFor(Function(i) i.FirstName, "*") %>
</div>
<div>
Last: <%= Html.TextBoxFor(Function(i) i.LastName)%>
<%= Html.ValidationMessageFor(Function(i) i.LastName, "*")%>
</div>
<div>
Email: <%= Html.TextBoxFor(Function(i) i.Email)%>
<%= Html.ValidationMessageFor(Function(i) i.Email, "*")%>
</div>
No luck. Is this right, and if not, what syntax do I need to use? Again, I'm using ASP.NET MVC 2.0, this is a view bound to a strongly typed model... does MVC 2 still not support the new language constructs in .NET 2010?
It's a VB.NET project and I correctly reference VB with this header:
<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <%@ Import Namespace="MvcSample.VB.Models.Validation" %>
Here is the definition of the Model class; the default project namespace is MvcSample.VB:
Namespace Models.Validation
Public Class ValidationSampleTestClass
<Required(ErrorMessage:="First name required.")> _
Public Property FirstName() As String
Get
Return m_FirstName
End Get
Set(ByVal value As String)
m_FirstName = value
End Set
End Property
Private m_FirstName As String
.
.
.
End Class
End Namespace
Thanks.