0

SERVER

Class Person
{
   public int id;
   public int SomeProp{ get{return id+1;}}
}

[WebMethod]
public Person GetPerson()
{
  return new Person();
}

CLIENT

I want to use the "SomeProp" Property in the Client Side.. How could i do it?

shay
  • 2,021
  • 1
  • 15
  • 17
  • 1
    [Why are you using ASMX](http://johnwsaunders3.wordpress.com/2011/12/07/more-reasons-to-not-use-asmx-services-in-new-code/)? How do you consume this code, with a service reference? What happens now when you try to use the property, does it exist on the class? Did you add a reference to the assembly or project containing `Person` to your client and did you check ["Reuse types in referenced assemblies"](http://stackoverflow.com/questions/6546462/service-reference-complex-types)? What do you _expect_ the property to do? What have you tried? – CodeCaster Dec 30 '13 at 11:34

1 Answers1

0

If I get it right, you don't want to just transfer the object from the server to the client. You want the client to be able to execute the code of the object, defined on the server. There are many ways to do this:

  1. Use a web service to replace the property functionality.

You could define a new WebMethod calculating the value of SomeProp for the specific Person.

  1. Use .NET Remoting

.NET remoting is like Java RMI. You create a local stub object on the client side and when you call its properties, the calculation is transparently executed on the server.

The key aspect of your issue, is that you want to execute on the client, a code which has been defined on the server. Therefore, the execution will have to hapen on the server side.

Hope I helped!

Pantelis Natsiavas
  • 5,293
  • 5
  • 21
  • 36