I have used PHP to return JSON from a database call by using the json_encode()
function on an array and parsing it with JQuery. Is there anyway to do this in ASP.Net Web Forms dynamically? In other words, not having to pre-determine how may columns are returned.
Asked
Active
Viewed 786 times
1

jwheron
- 2,553
- 2
- 30
- 40

Hank Allen
- 11
- 2
1 Answers
0
It's perfectly possible to use JSON in WebForms, see: this answer for details.
How early are you in your project? ASP.NET MVC is much better suited to using AJAX than Web Forms since it doesn't try to hide the stateless nature of HTTP and has a clearer way of working with the client/server and due to the more RESTful way of structuring server code, GET/POSTing to the URL of a controller action that has a JSONResult is much simpler.
If you haven't done too much, consider rewriting your UI layer to an ASP.NET MVC project or starting in that.

Community
- 1
- 1

StuperUser
- 10,555
- 13
- 78
- 137
-
Thanks for the reply. I have looked at MVC and would consider using it except for the fact we want to a Crystal Reports viewer control in the project. Even though there are many helpful things in the link above, none of them show a way to generate json as easy as php does. I need the results to be dynamic not having to create a class with a set number of values. – Hank Allen Dec 03 '11 at 19:22
-
Crystal Reports are fine since ASP.NET MVC is based on ASP.NET, see: http://stackoverflow.com/questions/348785/crystal-reports-in-asp-net-mvc. You can plug in crystal reports and get a proper Web framework for your web UI. – StuperUser Dec 03 '11 at 23:24
-
@HankAllen, not sure if I needed to @-mention you for yesterdays comment about Crystal Reports. – StuperUser Dec 05 '11 at 09:22