1

In previous asp.net projects we created server controls using the IScript interface 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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the reply. I agree that having more control over what goes on is great, but coming from asp.net sometimes things are missing and I wonder what are best practices. The blog post looks like it will point me in the right direction.
If this is indeed the solution to your question, I'd appreciate if you could mark it as so. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.