VB版的C#razor模板

时间:2011-08-02 20:49:54

标签: asp.net-mvc razor

我无法将以下c#/ Razor模板转换为VB

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

具体来说,我如何翻译@class

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

给出错误BC30201: Expression expected.

2 个答案:

答案 0 :(得分:3)

试试这个 -

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

答案 1 :(得分:0)

摆脱括号,它们不是必需的:

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

Telerik转换器运行良好,但转换Razor语法还有很多不足之处。 :)