3

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 ?

1 Answer 1

8

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.