加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-16 04:23:43 所属栏目:asp.Net 来源:网络整理
导读:我不确定为什么这个语法抱怨错误“输入未声明.由于保护级别可能无法访问”并且必须放置“@html(”以消除错误. 这个块抱怨错误 @Using (Html.BeginForm("GetUser","UserProfile",FormMethod.Post)) Enter User id :- @Html.TextBox("UserId",Model) -- This l
我不确定为什么这个语法抱怨错误“输入未声明.由于保护级别可能无法访问”并且必须放置“@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部分.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读