MVC 2: Html.TextBoxFor, etc. in VB.NET 2010

Posted by Brian on Stack Overflow See other posts from Stack Overflow or by Brian
Published on 2010-05-09T00:05:49Z Indexed on 2010/05/09 6:08 UTC
Read the original article Hit count: 859

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?

Thanks.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc