开发者

Use javascript variables as arguments in class method in C#

How can I use use javascript variables in C# cod开发者_StackOverflow社区e?

or

How can I assign C# variable value in javascript (from another javascript variable) in cshtml


Do you realize that your web pages are first processed on the server by IIS, using C#, and then transferred to the client, where JavaScript is executed?

This means that you technically can use your C# variables in your JavaScript code by something like

<script type="text/javascript">
var productID = @Model.ProductID;
</script>

but not vice versa.

Maybe you should consider using AJAX to make the additional requests to the server without the need to refresh the page.


You can use hidden variables. values can be assigned from js --> c# and vice versa. Or you can create properties in c# and access/assign values to them from js.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜