This is actual code from what I am working on that takes an ID from the query string, retrieves an object and parses to json. I am going to need to store and manipulate this data client-side. What is the best way to set the generated json string to a client-side object?
Note: NewObjectCase is a class with the method Get(strID) that returns a new Object. Tools.GetQueryObject(string key) is a metod that return the string value of the key
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.Script.Serialization;
using System.Web.UI.WebControls;
public partial class Testing: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strJson = new JavaScriptSerializer().Serialize(NewObjectCase.Get(Tools.GetQueryObject("id")));
// add in js to page that will set an client-side js object to this generated json
}
}
}