views:

197

answers:

1

I am using ASP.Net Ajax's Page Methods and I have an issue that an enumeration's definition is not being rendered. Here is what I have:

public class Contact
{
    public string FirstName{get;set;}
    public IList<PhoneNumber> PhoneNumbers{get;set;}
}

public class PhoneNumber
{
   public string Number{get;set;}
   public PhoneNumberType {get;set;}
}

public enum PhoneNumberType
{
   Home,
   Work,
   Fax,
   Cell
}

I then have a simple web method such as:

[WebMethod]
public static Contact GetContact(Guid id)
{
   return ....;
}

On the client side I end up with a MyNamespace.Contact class; however, I do not have a MyNamespace.PhoneNumber or MyNameSpace.PhoneNumberType. I've found that if I explicitly add fake webmethods that just return those types then client side types are rendered. Is there a way to force that enum to be rendered other then fake web methods?

I want the enum because I need to iterate through that List<> and based on the PhoneNumberType do something different. I'd rather not hardcode magic numbers or hardcode the enum deffinition.

A: 

I need to add GenerateScriptType attribute to the method signature.

So my page method is now

[WebMethod]
[GenerateScriptType(typeof(PhoneNumberType))]
[GenerateScriptType(typeof(PhoneNumber))]
public static Contact GetContact(Guid id)
{
}
JoshBerke

related questions