views:

36

answers:

1

From client side, I need to call a server method that is not static.

For example, I got the following user control ucData (private instance of code-behind) that is Databind in the load event.

The server method I need should return ucData.IsValid(). So it can't be static

Is there a way I can do that ?

+2  A: 

No...because there is no instance on the server to call the method on. Once the page is generated and sent to the client, there is no more context and all instances are destroyed.

Your best option is going to be to:

  1. Create a static method
  2. Pass that method the info needed to create the instance of the object you need
  3. Call the method on the instance you just created
  4. Return the results from your static method.
Justin Niessner