[英]adding code snippet to Razor (MVC 3)
I read the docs and apparently this should be acceptable: 我阅读了文档,显然这应该是可以接受的:
@{
string isDisplay = "";
if (@ViewBag.Name == "" || @ViewBag.Name == null)
{
isDisplay ="display:none;";
}
}
it's giving me a compliation error however though: 然而,它给了我一个赞美错误:
this is the error: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. 这是错误:编译错误说明:在编译服务此请求所需的资源期间发生错误。 Please review the following specific error details and modify your source code appropriately.
请查看以下特定错误详细信息并相应地修改源代码。
Compiler Error Message: CS1501: No overload for method 'Write' takes 0 arguments 编译器错误消息:CS1501:方法'Write'没有重载需要0个参数
any ideas? 有任何想法吗?
I don't have the compiler on hand, but this should be better 我手边没有编译器,但这应该更好
@{
string isDisplay = "";
if (ViewBag.Name == "" || ViewBag.Name == null)
{
isDisplay ="display:none;";
}
No need for the @ sign in a Razor Block 不需要Razor Block中的@符号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.