RickAndMSFT
RickAndMSFT

Reputation: 22810

VB version of C# razor template

I'm having trouble translating the following c#/Razor template into VB

@Html.TextBox("", String.Format("{0:d}", Model.Date.ToShortDateString()), 
    new { @class = "datefield" })

Specifically, how do I translate the @class

@Html.TextBox("", String.Format("{0:d}", Model.Date.ToShortDateString(), New With { @class = "datefield" })

gives the error BC30201: Expression expected.

Upvotes: 0

Views: 803

Answers (2)

ipr101
ipr101

Reputation: 24236

Try this -

Html.TextBox("", [String].Format("{0:d}", Model.[Date].ToShortDateString()), New With {.[class] = "datefield"})

Upvotes: 3

Ed DeGagne
Ed DeGagne

Reputation: 3269

Get rid of the brackets, they are not necessary:

@Html.TextBox("", String.Format("{0:d}", Model.Date.ToShortDateString()), New With {.class = "datefield"})

The Telerik converter works well, but converting Razor syntax leaves a lot to be desired. :)

Upvotes: 0

Related Questions