Loading ...
Sorry, an error occurred while loading the content.

Re: XHRDataSource, JSON and ASP.NET

Expand Messages
  • raul_p0pescu
    Can you check the output of the aspx page using either FireBug or Fiddler? Next step, try and validate your JSon @ http://www.jsonlint.com/
    Message 1 of 2 , Dec 4, 2008
    • 0 Attachment
      Can you check the output of the aspx page using either FireBug or
      Fiddler?

      Next step, try and validate your JSon @ http://www.jsonlint.com/


      --- In ydn-javascript@yahoogroups.com, "eka_gautama"
      <eka_gautama@...> wrote:
      >
      > Hi all,
      >
      > I need help how to use get data by using XHRDataSource, with JSON
      > format and ASP.NET/C#.
      >
      > So far here is my code and I have no success.
      >
      >
      > Here is my aspx.cs code:
      > ------------------------------
      > using System;
      > using System.Data;
      > using System.Configuration;
      > using System.Collections;
      > using System.Web;
      > using System.Web.Security;
      > using System.Web.UI;
      > using System.Web.UI.WebControls;
      > using System.Web.UI.WebControls.WebParts;
      > using System.Web.UI.HtmlControls;
      >
      > public partial class SampleData: System.Web.UI.Page
      > {
      > protected void Page_Load(object sender, EventArgs e)
      > {
      > Response.Clear();
      > Response.AppendHeader("Content-type", "application/json");
      >
      > Response.CacheControl = "no-cache";
      > Response.Write(@"{""transactions"":
      > [{""col"":""TEST1"",""value"":""12/1/2008"",""price"":""8000""},
      >
      > {""col"":""TEST2"",""value"":""12/2/2008"",""price"":""9000""},
      >
      > {""col"":""TEST3"",""value"":""12/3/2008"",""price"":""10000""},
      >
      > {""col"":""TEST4"",""value"":""12/4/2008"",""price"":""11000""},
      >
      > {""col"":""TEST5"",""value"":""12/5/2008"",""price"":""12000""}
      > ]
      > }");
      > Response.End();
      > }
      > }
      >
      > Here is the only code in my aspx file
      > ---------------------------------------
      > <%@ Page Language="C#" AutoEventWireup="true"
      > CodeFile="SampleData.aspx.cs" Inherits="SampleData" %>
      >
      >
      > And here is the Javascript
      > ---------------------------------
      > var sData = new YAHOO.util.XHRDataSource("SampleData.aspx" );
      >
      > sData.connMethodPost = true;
      > sData.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;
      > sData.responseSchema =
      > {
      > resultsList: "transactions",
      > fields: ["col","value","price"]
      > };
      >
      > Thank you.
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.