我不确定为什么这个语法会提示错误“未声明 Enter。由于保护级别,可能无法访问”并且必须输入“@html(”来消除错误。
这个块提示错误
@Using (Html.BeginForm("GetUser", "UserProfile", FormMethod.Post))
Enter User id :- @Html.TextBox("UserId",Model) -- This line must write in this way @Html("Enter User id :-")
<input type="submit" value="Submit data" /> --This line complain ">" expected"
End Using
如果这样重写代码,提示消失了,但输出显示“System.Web.MVC.Html”开头如下图
@Html.BeginForm("GetUser", "UserProfile", FormMethod.Post)
Enter User id :- @Html.TextBox("UserId",Model)
<input type="submit" value="Submit data" />
嗨 nemesv 如果使用
@<Text>
,这是提示 -->“使用必须以结束使用结束。”最佳答案
当您在 Using
内时阻止您在 Razor 中处于“代码模式”。
所以你需要使用 @:
(对于单行语句)或 @<text> .. </text>
(对于多行语句)切换回“文本模式”并输出 html。
随着使用 @:
:
@Using (Html.BeginForm("GetUser", "UserProfile", FormMethod.Post))
@:Enter User id :- @Html.TextBox("UserId",Model)
@:<input type="submit" value="Submit data" />
End Using
或使用
@<text>
:@Using (Html.BeginForm("GetUser", "UserProfile", FormMethod.Post))
@<text>Enter User id :-</text> @Html.TextBox("UserId",Model)
@<text><input type="submit" value="Submit data" /></text>
End Using
另见 Combining text, markup, and code in code blocks部分了解更多信息。
关于asp.net-mvc - 在 Razor VB.net MVC 中使用无法按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16414271/