开发者

Asp.Net Ajax - Call non-static method

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

For example, I got the follo开发者_JAVA技巧wing 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 ?


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜