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部分. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 当页面加载是AJAX历史记录点的结果时,如何检测客
- asp.net – 我可以在html源代码中看到ViewStateUserKey吗?
- AllowOnlyAlphanumericUserNames – 如何设置? (RC到RTM破
- asp.net – 如何告诉RadioButtonList不生成表
- 这是一个错误吗?或者它是ASP.NET 4(或MVC 2)中的设置?
- 如何在使用ASP.NET MVC的jQuery AJAX调用中触发“错误”回调
- asp.net – 自定义会话状态模块 – 使用ASP状态服务
- 消除代码中的坏味道,编写高质量代码
- asp.net – 后面的代码无法识别Web控件
- asp.net-mvc-3 – 在App_code文件夹中使用razor @helper使用
推荐文章
站长推荐
热点阅读