当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net mvc - 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.

网友答案:

Try this -

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

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. :)

分享给朋友:
您可能感兴趣的文章:
随机阅读: