Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was using Newtonsoft.Json along with some code from Rick Strahl, which helps serialize Data objects. his original post here: <a href="http://www.west-wind.com/Weblog/posts/471835.aspx" rel="nofollow noreferrer">http://www.west-wind.com/Weblog/posts/471835.aspx</a></p> <pre><code> public class ExtJSJsonResult : JsonResult { public bool success { get; set; } public string msg { get; set; } public override void ExecuteResult(ControllerContext context) { if (context == null){ throw new ArgumentNullException("context");} HttpResponseBase response = context.HttpContext.Response; if (!String.IsNullOrEmpty(ContentType)) { response.ContentType = ContentType; } else { response.ContentType = "application/json"; } if (ContentEncoding != null) { response.ContentEncoding = ContentEncoding; } if (Data != null) { Type type = Data.GetType(); response.Write(String.Format("{{success: true, msg: \"{0}\", data:", msg)); if (type == typeof(DataRow)) response.Write(JSonHelper.Serialize(Data, true)); else if (type == typeof(DataTable)) response.Write(JSonHelper.Serialize(Data, true)); else if (type == typeof(DataSet)) response.Write(JSonHelper.Serialize(Data, true)); else { JavaScriptSerializer serializer = new JavaScriptSerializer(); response.Write(serializer.Serialize(Data)); } response.Write("}"); } } } </code></pre> <p>using it</p> <pre><code>public ExtJSJsonResult View(int id) { bool success; string msg; DataRow dr=null; try { dr = DBService.GetRowById("oc.personeller", id); success = true; msg = "all ok"; } catch (Exception ex) { success = false; msg = ex.Message; } return new ExtJSJsonResult { success= success, msg = msg, Data = dr }; } </code></pre> <p>I hope this is of any use to someone besides me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload