C#中的MVC代码 - 什么是VB等价? [英] MVC code in C# - what is VB equivalent?

查看:83
本文介绍了C#中的MVC代码 - 什么是VB等价?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是转换为VB时遇到问题的c#代码:



Here's the c# code that I am having trouble converting to VB:

<div class="form-group">
@Html.LabelFor(m => m.FromName, new { @class = "col-md-2 control-label" })
  <div class="col-md-10">
    @Html.TextBoxFor(m => m.FromName, new { @class = "form-control" })
    @Html.ValidationMessageFor(m => m.FromName)
  </div>
</div>



我遇到问题的c#行就是那些带有@Html语法的行。



我有的那些VB代码(下面)有这个错误m.FromName:

后期绑定操作无法转换为表达式树



这是我在VB中所拥有的:


The c# line I'm having trouble with is those ones with @Html syntax.

The VB code (below) that I have for those has this error on m.FromName:
"Late binding operations cannot be converted to an expression tree"

Here's what I have in VB:

@Html.LabelFor(Function(m) m.FromName, New With {Key .class = "col-md-2 control-label"})

推荐答案

每次需要翻译时,您都不必提出这样的问题。大多数(如果不是全部)这项工作都可以自动完成。请参阅我以前的回答:代码解释,C#到VB .NET [ ^ ]。



使用ASP.NET可能需要更多努力,但您仍然可以轻松找出翻译本身。



-SA
You don't have to ask such questions every time you need a translation. Most if not all of this work can be done automatically. Please see my past answer: Code Interpretation, C# to VB.NET[^].

With ASP.NET it may require some more effort, but you still can easily figure out the translation itself.

—SA


@Html.LabelFor(m => m.FromName, new { @class = "col-md-2 control-label" })
<label for="FromName">From Name</label>

@Html.TextBoxFor(m => m.FromName, new { @class = "form-control" })
<input type="text" class="from-control" name="FromName" id="FromName">
</input>





等效的HTML代码写在剃刀下面代码 - 现在将其转换为VB语法。





-KR



Equivalent HTML code is written below the razor code - Now convert it to your VB syntax.


-KR


这篇关于C#中的MVC代码 - 什么是VB等价?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆