使用jquery,javascript在asp.net中调用非静态函数 [英] Calling a non static function in asp.net with jquery,javascript
本文介绍了使用jquery,javascript在asp.net中调用非静态函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从javascript调用非静态方法?
我正在使用 pagemethod.methodName();
我使用时工作正常:
How can I call a non static method from javascript?
I am using pagemethod.methodName();
It works fine when I use:
[WebMethod]
Public Static void methodName()
{
//Nothing
}
我想用javascript调用非静态方法。
有什么方法可以调用非静态方法?请帮忙。
提前致谢。
I want to call a non static method from javascript.
Is there any way to call a non static method? Please help.
Thanks in advance.
推荐答案
你可以使用Ajax dll
看到这个链接
http://msdn.microsoft.com/en-us/library/aa479042.aspx [ ^ ]
u can use Ajax dll for that
see this link
http://msdn.microsoft.com/en-us/library/aa479042.aspx[^]
您好,
据我所知,这是不可能的。
从逻辑方面来说,这也没有任何意义,因为对于非静态方法(一个实例方法)你首先需要一个任何对象的实例,但是Ajax请求只执行一个方法并且没有实例化一个对象。
也许你会在远程处理工具中找到解决方案,例如 WebOrb [ ^ ]。在Weborb中,如果您调用的函数是实例方法,则会创建一个实例。
无论如何,为什么需要静态方法来执行?您不会在ajax请求中获得正确的页面上下文(或任何其他上下文)。您尝试这样做是否有特定原因?
希望这会有所帮助。
祝您好运,祝你生日愉快,
Stops
---------
查看我的网站 http://dotnetcorner.ch/ 和我的博客http://blog.dotnetcorner.ch/
Hello,
As far as I know, this is not possible.
From the logical side, this also would not make any sense, because for a non-static method (a instance method) you would need first an instance of any object, but the Ajax request just executes a method and does not instantiate a object.
Perhaps you will find a solution in remoting tools like WebOrb[^] for example. In Weborb, a instance will be created if the function you call is a instance-method.
Anyway, why you would need a static method to be executed? You would not get a correct page context (or any other context) in a ajax request. Is there a specific reason you try to do this?
Hope this helps.
Best regards and have a nice day,
Stops
---------
Check out my website http://dotnetcorner.ch/ and my blog http://blog.dotnetcorner.ch/
不可能,您需要使用静态方法,然后在那里制作自己的对象,所以基本上你需要知道asp.net中的面向对象
no that's not possible, you need to use static methods and then make your own objects there , so basically you need to know object oriented in asp.net
这篇关于使用jquery,javascript在asp.net中调用非静态函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文