【问题标题】:Changing Field Name Value in ViewModel在 ViewModel 中更改字段名称值
【发布时间】:2011-01-28 15:21:18
【问题描述】:

有什么方法可以更改 Viewmodel 中属性的 FieldName 值?我想对属性使用标准命名约定,但让 viewmodel 返回其他内容。这很重要,因为我有一个要求属性为小写的 json 请求。

我尝试过同时使用 XMLAttributes 和 DataMembers,但这些方法都不起作用。这些来自以下问题。

Serialize .Net object to json, controlled using xml attributes

JavaScriptSerializer.Deserialize - how to change field names

所以,重申一下,我需要这样的东西

 public string Start { get; set; } 

显示为

 viewmodel.start

而不是

viewmodel.Start

当我将视图模型传递给 getJson 请求中的回调时

【问题讨论】:

    标签: json model-view-controller fullcalendar


    【解决方案1】:

    向你的模型添加一个额外的属性怎么样?

    public string start {get {return Start;}}
    

    【讨论】:

      猜你喜欢
      • 2011-05-24
      • 1970-01-01
      • 1970-01-01
      • 2013-09-02
      • 2015-01-07
      • 1970-01-01
      • 1970-01-01
      • 2016-04-10
      • 1970-01-01
      相关资源
      最近更新 更多