title: Returning JSON object from an ASP.NET page
body: <p>In my particular situation, I have a couple of solutions to my problem. I want to find out which one is more feasible. In this case, I can also achieve my goal by returning a JSON object from my server side code; however, I do not know how it is done and what the best way of doing it is.</p>
  
  <p>First off, I don't need a full aspx page as I only need a response returned from code. So, do I use web services, a handler, or is there any other specific way to do this?</p>
  
  <p>Is this solution feasible? Do I build the JSON string using the <code>StringBuilder</code> class and inject that string into the target aspx page? Are there any precautions or things that I should be aware of?</p>
  
  <p>I appreciate your ideas.</p>
  
  <p>Regards,</p>
  
  <p>Kemal</p>
  
  <p><strong>------------UPDATE !------------</strong></p>
  
  <p>Suppose I have a JSON object in my userlist.aspx page, which then I use with jQuery...</p>
  
  <pre><code>{"menu": {
    "id": "color1",
    "value": "color",
    "popup": {
      "menuitem": [
        {"value": "Red"},
        {"value": "Green"},
        {"value": "Yellow"}
      ]
    }
  }} // example taken from the json.org/example page
  </code></pre>
  
  <p>Now when I want to add a new menu items from my aspx page, what do I do... I think this way my question is more specific...</p>
  
  <p>Lets assume I create a new string in my aspx code, as such <code>"{"value": "Blue"}</code>. How do I inject this into the already existing itemlist in the target page? Or is this not the correct approach to this kind of situation? If not, how else can it be achieved?</p>
  
  <p>Also, if I wanted to fire a jQuery event when a new item is added to this list, how is this achieved?</p>
  
  <p><strong>------------UPDATE 2 on 26 August 2015 ------------</strong></p>
  
  <p>By the time I asked this question, the way I was approaching the problem was in another aspect. I am now more proficient in the subject and can gladly accept the most voted answer since the approach to this question clearly should not include the already existing JSON and output a new one from the code as <code>@DavGarcia</code> also suggests.</p>