开发者

how to define dynamic variable in javascript

when i define in javascript

var whoami = @ViewBag.myname

it is not wo开发者_如何学Pythonrk or render they render

var whoami = ;

i am trying it @(ViewBag.myname) // not worked too.

are their any way to do this in raor MVC 3


Is @ViewBag.myname empty?

Enclose the variable in quotes, so to have a correct javascript string:

var whoami = "@ViewBag.myname";

also ensure that myname doesn't contain quotes too (or escape them).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜