admin管理员组文章数量:1023738
Here's what I'm trying to do:
$(document).ready(function () {
@if (ViewBag.VerifyIfLoggedIn) {
$("#needlogin-popup").dialog({
modal: true,
closeOnEscape: true,
minHeight: 384,
minWidth: 596,
resizable: false,
show: {
effect: 'slide',
duration: 500,
direction: 'up'
},
hide: {
effect: 'slide',
duration: 250,
direction: 'up'
},
title: 'Inicie Sesion'
});
}
});
If something is true, then output this Javascript code to the page.
But I'm getting the error:
CS1056: Unexpected character '$'
How can I tell Razor to stop parsing and output whatever is in the conditional statement?
Here's what I'm trying to do:
$(document).ready(function () {
@if (ViewBag.VerifyIfLoggedIn) {
$("#needlogin-popup").dialog({
modal: true,
closeOnEscape: true,
minHeight: 384,
minWidth: 596,
resizable: false,
show: {
effect: 'slide',
duration: 500,
direction: 'up'
},
hide: {
effect: 'slide',
duration: 250,
direction: 'up'
},
title: 'Inicie Sesion'
});
}
});
If something is true, then output this Javascript code to the page.
But I'm getting the error:
CS1056: Unexpected character '$'
How can I tell Razor to stop parsing and output whatever is in the conditional statement?
Share Improve this question asked May 4, 2012 at 0:59 Only Bolivian HereOnly Bolivian Here 36.8k65 gold badges167 silver badges257 bronze badges1 Answer
Reset to default 10Use <text>...</text>
around the code.
Read on how it works here:
http://weblogs.asp/scottgu/archive/2010/12/15/asp-net-mvc-3-razor-s-and-lt-text-gt-syntax.aspx
The tag is an element that is treated specially by Razor. It causes Razor to interpret the inner contents of the block as content, and to not render the containing tag element (meaning only the inner contents of the element will be rendered – the tag itself will not).
This makes it convenient when you want to render multi-line content blocks that are not wrapped by an HTML element.
$(document).ready(function () {
@if (ViewBag.VerifyIfLoggedIn) {
<text>$("#needlogin-popup").dialog({
modal: true,
closeOnEscape: true,
minHeight: 384,
minWidth: 596,
resizable: false,
show: {
effect: 'slide',
duration: 500,
direction: 'up'
},
hide: {
effect: 'slide',
duration: 250,
direction: 'up'
},
title: 'Inicie Sesion'
}); </text>
}
});
Here's what I'm trying to do:
$(document).ready(function () {
@if (ViewBag.VerifyIfLoggedIn) {
$("#needlogin-popup").dialog({
modal: true,
closeOnEscape: true,
minHeight: 384,
minWidth: 596,
resizable: false,
show: {
effect: 'slide',
duration: 500,
direction: 'up'
},
hide: {
effect: 'slide',
duration: 250,
direction: 'up'
},
title: 'Inicie Sesion'
});
}
});
If something is true, then output this Javascript code to the page.
But I'm getting the error:
CS1056: Unexpected character '$'
How can I tell Razor to stop parsing and output whatever is in the conditional statement?
Here's what I'm trying to do:
$(document).ready(function () {
@if (ViewBag.VerifyIfLoggedIn) {
$("#needlogin-popup").dialog({
modal: true,
closeOnEscape: true,
minHeight: 384,
minWidth: 596,
resizable: false,
show: {
effect: 'slide',
duration: 500,
direction: 'up'
},
hide: {
effect: 'slide',
duration: 250,
direction: 'up'
},
title: 'Inicie Sesion'
});
}
});
If something is true, then output this Javascript code to the page.
But I'm getting the error:
CS1056: Unexpected character '$'
How can I tell Razor to stop parsing and output whatever is in the conditional statement?
Share Improve this question asked May 4, 2012 at 0:59 Only Bolivian HereOnly Bolivian Here 36.8k65 gold badges167 silver badges257 bronze badges1 Answer
Reset to default 10Use <text>...</text>
around the code.
Read on how it works here:
http://weblogs.asp/scottgu/archive/2010/12/15/asp-net-mvc-3-razor-s-and-lt-text-gt-syntax.aspx
The tag is an element that is treated specially by Razor. It causes Razor to interpret the inner contents of the block as content, and to not render the containing tag element (meaning only the inner contents of the element will be rendered – the tag itself will not).
This makes it convenient when you want to render multi-line content blocks that are not wrapped by an HTML element.
$(document).ready(function () {
@if (ViewBag.VerifyIfLoggedIn) {
<text>$("#needlogin-popup").dialog({
modal: true,
closeOnEscape: true,
minHeight: 384,
minWidth: 596,
resizable: false,
show: {
effect: 'slide',
duration: 500,
direction: 'up'
},
hide: {
effect: 'slide',
duration: 250,
direction: 'up'
},
title: 'Inicie Sesion'
}); </text>
}
});
本文标签: javascriptMVC3 Razor not recognizing when to stop parsingStack Overflow
版权声明:本文标题:javascript - MVC3 Razor not recognizing when to stop parsing - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745517580a2154145.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论