views:

77

answers:

2

I'm trying to avoid the use of magic strings as much as I can, but I can't find the correct syntax for VB to bind a single model like is shown in this c# example.

Can anyone point me in the right direction?

(currently the below says "expected end of statement" under the Model text)

<% Dim FormObject As Form = (Form)Model %>

EDIT:

A simple directcast was need (sorry for the dumb question)

<%  Dim FormObject As Form = DirectCast(Model, Form)%>
+2  A: 

What you're trying to port is a cast operator. Try the following code.

<% Dim FormObject As Form = DirectCast(Model, Form) %>
JaredPar
+1  A: 

you have to make your view strongly typed like this either you use C# or VB.NET:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<FormObject>" %>

so that when you want to use it you don't need to cast it

<% Dim FormObject As Form = Model %>
Marwan Aouida