tso*_*tan 8 vb.net asp.net-mvc razor
我不确定为什么这个语法抱怨错误"输入未声明.由于保护级别可能无法访问"并且必须放置"@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
Run Code Online (Sandbox Code Playgroud)
如果以这种方式重写代码,抱怨就消失了,但输出显示"System.Web.MVC.Html",如下图所示
@Html.BeginForm("GetUser", "UserProfile", FormMethod.Post)
Enter User id :- @Html.TextBox("UserId",Model)
<input type="submit" value="Submit data" />
Run Code Online (Sandbox Code Playgroud)
嗨nemesv如果使用@<Text>
,它会抱怨这个 - >"使用必须以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
Run Code Online (Sandbox Code Playgroud)
或使用@<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
Run Code Online (Sandbox Code Playgroud)
有关详细信息,另请参阅" 在代码块中组合文本,标记和代码"部分.
归档时间: |
|
查看次数: |
6355 次 |
最近记录: |