using javascript variable in MVC3 Razor view engine

后端 未结 2 649
天命终不由人
天命终不由人 2020-12-01 07:33

Is it possible?

@Html.ActionLink( \"Link text\", \"Action Name\", new { id = *JAVASCRIPT VARIABLE* })

Please explain with example code.

2条回答
  •  醉酒成梦
    2020-12-01 08:06

    No it is not possible, because .NET MVC 3 is server side code and is evaluated before being sent to the client, and javascript is Client side code which runs only once it is ON the client

    BUT the reverse is possible:

    var jsVar = "@yourMvcVar";
    

提交回复
热议问题