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.
精彩评论