The key is to output JS on the plain text content, so that the browser to parse the JS code
<script>
Bui.use (' Common/main ', function () {
var config = [
{
ID: ' 1 ',
Menu
[
@{
int ruiyalel = (int) session["Ruiyalev"];
int happyfamilylel = (int) session["Happyfamilylev"];
if (Ruiyalel > 0) {
<text>
{
Text: ' Swiss website ', items: [{id: ' 3 ', text: ' Swiss News ', href: ' Dbsystem/ruiya/news '},]
},
</text>
}
if (Happyfamilylel > 0) {
<text>
{
Text: ' Family fun ', items: [{id: ' 4 ', Text: ' News management ', href: ' Dbsystem/happyfamily/news '},
{ID: ' 5 ', Text: ' Activity management ', href: ' dbsystem/happyfamily/activity '},
{ID: ' 6 ', Text: ' Integrated Management ', href: ' Dbsystem/happyfamily/generalmes '},]
},
</text>
}
}
]
}];
New Pageutil.mainpage ({
Modulesconfig:config
});
});
</script>
@: Indicates the direct output string after
<text></text> indicates that the output is a string
Either way, note that <text> is not an HTML tag, he is a razor syntax that is specifically used to output strings.
MVC Razor with JavaScript (embedded razor in JS)