Click here to Skip to main content
16,013,730 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am developing a webiste in ASP.NET. On one of the pages page named menu.aspx, with the help of a certain login, I am getting the output in this format

foo({"1":"Jeff","2":"Mik","5":"Tom"});

I am using this code to get the output on the JSON form.

outputText += Convert.ToString(k.GetValue(0));
              for (Int32 i = 1; i < k.Length; i++)
              {
                  outputText += "," + Convert.ToString(k.GetValue(i));
              }
              //
              outputText += "}" +");";
              Response.Clear();
              Response.Write(outputText);
              Response.ContentType = "application/json";


However, I must get the output only in simple JSON on the page without any HTML.

For eg: Here's the screenshot showing the source of the output page. http://i.imgur.com/faUtY.jpg[^]

Notice that it has only the JSON string as the output.

And here's the screenshot showing the output page source (with HTML). http://i.imgur.com/gIxzR.jpg[^] .This HTML is what I have to remove. How can do I do this?
The full code of menu.aspx.cs is putup here. http://pastebin.com/M14Srrgf[^]
Posted
Updated 21-Jan-11 17:00pm
v2

1 solution

The best way sould be using a webmethod returning string type or you could place the functionality into a spearate page that doesn't have any HTML/ASP-Control markup in its aspx page. All close would be in the code-behind file only.

Best Regards,
Manfred
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900