微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

asp.net-mvc – 在Razor VB.net中使用MVC无法按预期工作

我不确定为什么这个语法抱怨错误“输入未声明.由于保护级别可能无法访问”并且必须放置“@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",FormMethod.Post)
       Enter User id :-   @Html.TextBox("UserId",Model) 

    <input type="submit" value="Submit  data" />

hi nemesv如果使用@< Text>
,它抱怨这个 – >“使用必须以结束使用结束.”

解决方法

当您在使用块内时,您在Razor中处于“代码模式”.

所以你需要使用@ :(用于单行语句)或@< text> ..< / text> (对于多行语句)切换回“文本模式”并输出html.

使用@ ::

@Using (Html.BeginForm("GetUser",FormMethod.Post))
      @:Enter User id :-  @Html.TextBox("UserId",Model)  
      @:<input type="submit" value="Submit  data" />
End Using

或使用@< text>:

@Using (Html.BeginForm("GetUser",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部分.

原文地址:https://www.jb51.cc/aspnet/248144.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐