开发者

How to add an additional type to the ASP.NET script manager so that the script is generated?

开发者 https://www.devze.com 2022-12-19 02:17 出处:网络
When I add a service 开发者_StackOverflowreference to my script manager, all the required C# classes are generated in the script, but one. This particular class is used as follows:

When I add a service 开发者_StackOverflowreference to my script manager, all the required C# classes are generated in the script, but one. This particular class is used as follows:

[DataContract]
public class MyObject {
  [DataMember]
  public string Id { get; set; }

  [DataMember]
  public bool Value { get; set; }
}

[DataContract]
public class MyData {
  [DataMember]
  public string Name { get; set; }

  [DataMember]
  public List<MyObject> ObjectInfo { get; set; }
}

[WebService]
[ScriptService]
public class MyService {
  [WebMethod(EnableSession = true)]
  public void AddNewData(IEnumerable<MyData> dataObjects) {
    ... some code
  }
}

No script is generated for the class MyObject. Am I missing something obvious?

Thanks in advance...


Try adding the GenerateScriptType attribute to your web service.

[WebService]
[ScriptService]
[GenerateScriptType(typeof(MyObject))]
public class MyService {
}

I found this in Chapter 5 (page 157) of ASP.NET AJAX in Action.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号