将C#Razor视图语法转换为VB.net

时间:2012-03-21 10:05:15

标签: asp.net asp.net-mvc vb.net razor

我是Razor视图语法的新手,因为大多数示例都在C#中,我需要帮助将下面的Razor语法转换为vb.net

<div>
    @using (Html.BeginForm())
    {
        @Html.ValidationSummary()
        <p>Your Name : @Html.TextBox("Name")</p>
        <p>Your Age Range : 
            @Html.DropDownList("IsEligibleAge", new[] {
                new SelectListItem() {Text = "Below 18", Value = bool.FalseString},
                new SelectListItem() {Text = "18 and Above", Value = bool.TrueString}
            }, "Please select your age")
        </p>
        <input type="submit" value="Submit Data" />
    }
</div>

1 个答案:

答案 0 :(得分:5)

我希望它有效:

<div>
    @using (Html.BeginForm())     
        @Html.ValidationSummary()
        @<p>Your Name : @Html.TextBox("Name") </p>
        @<p>Your Age Range : 
            @Html.DropDownList("IsEligibleAge", { 
                New SelectListItem() With {.Text = "Below 18", .Value = Boolean.FalseString}, 
                New SelectListItem() With {.Text = "18 and Above", .Value = Boolean.TrueString}
            }, "Please select your age")
        </p>
        @<input type="submit" value="Submit Data" />
    end using
</div>

我使用这篇关于Razor and VB.NET的好文章进行翻译。