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部分.

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....