我不知道为什么这个语法会抱怨错误“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" />
hi nemesv if Use @<Text>
,it's complain this -->"Using must end with End Using."
当你在一个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
另请参阅在代码块中组合文本、标记和代码部分了解更多信息。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)