简体   繁体   English

将此C#模板转换为等效的VB

[英]Convert this C# template to VB equivalent

can anyone please translate this into the equivalent for asp.net MVC with VB please? 谁能将它翻译成带有VB的asp.net MVC的等效语言?

(I'm trying to add a template DateTime picker to the Editor templates - and all I can find is the C# version) (我正在尝试将模板DateTime选择器添加到编辑器模板中-我所能找到的只是C#版本)

@model DateTime

Using Date Template

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

I get an error at the first curly bracket, advising type or "with" expected. 我在第一个花括号处出现错误,建议使用类型或“ with”。

Thanks for your help, 谢谢你的帮助,

Mark 标记

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

在“ New With”匿名类型参数之前,您不需要“ @”。

There are tons of C# to vb converters online. 在线有大量的C#到VB转换器。 Here is the output from the one I use Keep in mind that they aren't foolproof, but they do give you at least a starting point. 这是我使用的输出。请记住,它们并不是万无一失的,但它们至少可以为您提供一个起点。 http://www.developerfusion.com/tools/convert/csharp-to-vb/ http://www.developerfusion.com/tools/convert/csharp-to-vb/

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

The VB.Net Anonymous Type Syntax uses New With and a dot in front of the property names. VB.Net匿名类型语法在属性名称前使用“ New With和一个点。 Try the following 尝试以下

new with { .@class = "datefield", .type = "date"  }

Note: I'm not 100% sure if the .@class will work with razor. 注:我不是100%肯定,如果.@class将与剃刀工作。 You may need to escape it in some way. 您可能需要以某种方式对其进行转义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM