VB.NET Razor语法

VB.NET Razor语法,vb.net,razor,Vb.net,Razor,为什么这样做有效 <h2>Index</h2> @Html.ActionLink("Create New", "Create") @Using (Html.BeginForm()) @<p> Title: @Html.TextBox("SearchString") <br /> <input type="submit" value="Filter" /> </p> End Us

为什么这样做有效

<h2>Index</h2>
@Html.ActionLink("Create New", "Create")
@Using (Html.BeginForm())
    @<p>
        Title: @Html.TextBox("SearchString") <br />
        <input type="submit" value="Filter" />
    </p>
End Using
索引
@ActionLink(“新建”、“创建”)
@使用(Html.BeginForm())
@
标题:@Html.TextBox(“搜索字符串”)

终端使用
但事实并非如此

<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
@Using (Html.BeginForm())
    @<p>
        Title: @Html.TextBox("SearchString") <br />
        <input type="submit" value="Filter" />
    </p>
End Using
</p>
索引

@ActionLink(“新建”、“创建”)
@使用(Html.BeginForm())
@
标题:@Html.TextBox(“搜索字符串”)

终端使用

保存时,VS将其更改为

...
@Using (Html.BeginForm())
@
<p>
...
。。。
@使用(Html.BeginForm())
@

...
这给html不是代码带来了很多错误

编辑:整个文件,不知道是否相关

编辑2:我正试图从本教程中复制一个C代码


@ActionLink(“新建”、“创建”)
@使用(Html.BeginForm()){
标题:@Html.TextBox(“搜索字符串”)

}


您可以使用段落标记作为表单的容器 尝试按div按如下方式重播它:

 <h2>Index</h2>
<div>
    @Html.ActionLink("Create New", "Create")
    @Using (Html.BeginForm())

        @<p>
            Title: @Html.TextBox("SearchString") <br />
            <input type="submit" value="Filter" />
        </p>

    End Using
</div> 
索引
@ActionLink(“新建”、“创建”)
@使用(Html.BeginForm())
@
标题:@Html.TextBox(“搜索字符串”)

终端使用
我没有想到教程中可能有错误。非常感谢。
 <h2>Index</h2>
<div>
    @Html.ActionLink("Create New", "Create")
    @Using (Html.BeginForm())

        @<p>
            Title: @Html.TextBox("SearchString") <br />
            <input type="submit" value="Filter" />
        </p>

    End Using
</div>