Questo è il codice effettivo da quello a cui sto lavorando che accetta un ID dalla stringa di query, recupera un oggetto e analizza in json. Avrò bisogno di archiviare e manipolare questi dati lato client. Qual è il modo migliore per impostare la stringa JSON generata su un oggetto lato client?Quali sono le migliori pratiche per l'aggiunta dinamica di javascript in una pagina asp.net?
Nota: NewObjectCase è una classe con il metodo Get (strID) che restituisce un nuovo oggetto. Tools.GetQueryObject (string key) è un Metod che restituisce il valore stringa della chiave
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
}
}
}