简体   繁体   English

如何从javascript返回值分配给razor变量?

[英]How to assign value from javascript return to razor variable?

Here is the example: 这是示例:

<script> function getString(){ var a = "something"; return a;} </script>

and razor example: 和剃刀的例子:

string a = "javascript return" or getString();

is that possible? 那可能吗?

You wont be able to convert JavaScript variable/function call to a Razor variable. 您将无法将JavaScript变量/函数调用转换为Razor变量。 Razor variable is handled by Razor engine on server where as JavaScript on the other hand is a client side language running on the client. Razor变量由服务器的Razor引擎处理, 而另一方面JavaScript是在客户端上运行的客户端语言。

Razor is a view engine used by the ASP.NET MVC framework running on the server to produce some HTML template. Razor是由服务器上运行的ASP.NET MVC框架使用的视图引擎,用于生成一些HTML模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM