c# - How to give a alias to class name using Attributes of System.ComponentModel namespace -
when rendering data of class using json web page class name being rendered full name including complete namespace way using attribute in c# can give alias class name.
i dont want expose complete name of class {"mycompany.productname.classname":"somevalue"}
i want render {"classname":"somevalue"}
below code of receivings.aspx.cs //contains interaction logic receivings.aspx
public partial class receivings : page { [webmethod(enablesession = true)] public static object getreceivingdetails(int pid) { try { recdetail recdetail = new accountsbl().getreceivingdetails(pid); //return result jtable return new { result = "ok", records = recdetail }; } catch (exception ex) { return new { result = "error", message = ex.message }; } } } json rendered shown below

here json shown in above screenshot
{"d":{"result":"ok","records":{"__type":"erp.models.accounts.recdetail","id":0,"mode":0,"amount":0,"catid":0,"cattypeid":0,"recid":0,"payerid":0,"cash":{"id":1,"thousand":30,"fivehundred":0,"hundred":0,"fifty":0,"twenty":0,"ten":0,"five":0,"two":0,"one":0,"recid":0,"payerid":0,"cashrec":30000,"notes":"xccxvcxcvzc"},"cheque":{"id":5,"bank":"hdfc","branch":"6868","no":"452326424","date":"5/5/2013 12:00:00 am","amount":10000,"recid":0,"payerid":0,"notes":"asdfasdfasdf"},"dd":{"id":1,"bank":"sbi","branch":"354356","no":"141234123","date":"5/5/2013 12:00:00 am","amount":10000,"recid":0,"payerid":0,"notes":"sdfgsfdgsdfg"}}}} below recdetail class
namespace erp.models.accounts { [erpattributes("recdetail")] public class recdetail { public int id { get; set; } public byte mode { get; set; } public int amount { get; set; } public byte catid { get; set; } public byte cattypeid { get; set; } public int recid { get; set; } public int payerid { get; set; } public cash cash { get; set; } public cheque cheque { get; set; } public dd dd { get; set; } } }
Comments
Post a Comment