开发者

Asp.net mvc client side data?

开发者 https://www.devze.com 2023-04-12 15:18 出处:网络
In previous asp.net projects we created server controls using the IScript int开发者_StackOverflow社区erface to create client side objects for controls.It was a great way to pass information between th

In previous asp.net projects we created server controls using the IScript int开发者_StackOverflow社区erface to create client side objects for controls. It was a great way to pass information between the server and client. Is there any equivilent in 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. 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.

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. You can read about how everything works together in this blog post.

0

精彩评论

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

关注公众号