2

i want to print following output by fetching data from sql in C#. I dont want to use asp.net web service. I just want to print JSON output on .aspx page.

{
    "dept_updates":
    [
        {
            "id":"11",
            "subject":"zzz",
            "utime":"Saturday 4th July 2015 05:20:29",
            "description":"zz","branch":"Computer Engineering",
            "flag":"http:\/\/www.emample.com\/login\/image\/5.jpg",
            "uploadedby":"JD"
        },
        {
            "id":"10",
            "subject":"hhh",
            "utime":"Monday 25th May 2015 02:48:46",
            "description":"hh","branch":"Information Technology",
            "flag":"http:\/\/www.example.com\/login\/image\/1\,
            "uploadedby":"JD"
         }

    ]
}

1 Answer 1

1

I think the most straightforward way would be this:

<pre><%Response.Write(HttpUtility.HtmlEncode("foo")); %></pre>

(replace "foo" with JSON)

Notice how the pre should keep the spacing, and the HtmlCode should do that nothing bad comes out on screen.

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

3 Comments

thanks for answering. But can you give me whole code from fetching data from database to printing it in JSON using C#
Sorry. My advice is you add a new datamodel toss tables into there and then use Link to Entities.
sorry, I am not getting. Because i dont have that much of knowledge. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.