简体   繁体   English

ASP.NET MVC客户端数据?

[英]Asp.net mvc client side data?

In previous asp.net projects we created server controls using the IScript interface to create client side objects for controls. 在以前的asp.net项目中,我们使用IScript接口创建服务器控件,以创建控件的客户端对象。 It was a great way to pass information between the server and client. 这是在服务器和客户端之间传递信息的好方法。 Is there any equivilent in asp.net mvc? 在ASP.NET MVC中有什么对等之处吗? I've seen reference to hidden form variables but that seems like such a step back. 我已经看到了对隐藏的表单变量的引用,但这似乎又退了一步。 Thanks in advance for any help. 在此先感谢您的帮助。

In ASP.NET MVC, there's less magic than what's baked in to WebForms. 在ASP.NET MVC中,没有比WebForms强大的魔力。 This is actually one of MVC's greatest features, since it doesn't try to abstract (in all the wrong ways) HTTP, JavaScript, CSS and HTML into something unrecognizable, but instead give you access to the bare metal so you actually have control (no pun intended) of what goes on in the communication between the browser and the server. 实际上,这是MVC的最大功能之一,因为它不会尝试(以所有错误的方式)将HTTP,JavaScript,CSS和HTML提取为无法识别的内容,而是让您访问裸机,因此您实际上可以控制(浏览器和服务器之间的通信发生了什么?

In ASP.NET MVC, the easiest way to communicate .NET classes to JavaScript objects is to serialize them as JSON with the JsonResult class and deserialize the JSON into a JavaScript object graph with the jQuery.getJSON() method . 在ASP.NET MVC中,将.NET类与JavaScript对象通信的最简单方法是使用JsonResult将它们序列化为JSON ,然后使用jQuery.getJSON()方法将JSON反序列化为JavaScript对象图。 You can read about how everything works together in this blog post . 您可以在此博客文章中了解所有内容如何协同工作

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

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