How to pass a value to razor variable from javascript variable?

后端 未结 7 987
小鲜肉
小鲜肉 2020-11-27 19:43

How to pass a value to razor variable from javascript variable, is it possible asp.net mvc razor view engine?

@{
    int a = 0;
}



        
7条回答
  •  攒了一身酷
    2020-11-27 20:37

    But it would be possible if one were used in place of the variable in @html.Hidden field. As in this example.

    @Html.Hidden("myVar", 0);
    

    set the field per script:

    
    

    I hope I can at least offer no small Workaround.

提交回复
热议问题