Projenize System.Web.Extensions u ref edin.Kodumuz sayesinde Generic listimizi json olarak dışarı aldık.
1: using System;
2: using System.Collections.Generic;
3: using System.Web.Script.Serialization;
4: namespace Testing
5: {
6: public partial class jsonserialize : System.Web.UI.Page
7: {
8: protected void Page_Load(object sender, EventArgs e)
9: {
10: List<Listem> liste = new List<Listem>();
11: for (int i = 0; i < 10; i++)
12: {
13: Listem eleman = new Listem();
14: eleman.ID = i;
15: eleman.Isim = ((char)i).ToString();
16: liste.Add(eleman);
17: }
18:
19: var jsonSerialiser = new JavaScriptSerializer();
20: var json = jsonSerialiser.Serialize(liste);
21: Literal1.Text = json;
22: }
23: }
24: class Listem
25: {
26: public int ID { get; set; }
27: public string Isim { get; set; }
28:
29: }
30: }
Hiç yorum yok:
Yorum Gönder