为什么WebMethod在WebForm背后的代码中是静态的 [英] Why the WebMethod is static in code behind WebForm
本文介绍了为什么WebMethod在WebForm背后的代码中是静态的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在PageMethod后面调用代码,WebServices服务使用ajax()函数来使用数据。当有必要从.aspx.cs页面后面的代码中使用数据时,我们声明了一些静态函数,然后我们使用ajax()函数来使用这个函数。
http://www.c-sharpcorner.com/UploadFile/dacca2/static-webmethod-in-code-behind-webform/ [ ^ ]
I am calling code behind PageMethod, WebServices services to consume data using the ajax() function. When there is a necessity to consume data from code behind of the .aspx.cs page we declare some static function and then we consume this function using the ajax() function.
http://www.c-sharpcorner.com/UploadFile/dacca2/static-webmethod-in-code-behind-webform/[^]
推荐答案
为什么不问这个代码的作者?没有其他人可以帮助解决别人的代码中的解决方案。
首先我想到的是:由于开发人员的邋。。我认为没有理由说这种方法应该是静态的。请参阅: http://msdn.microsoft.com/en-us /library/byxd99hx%28v=vs.90%29.aspx [ ^ ]。
一些免责声明:当我说我想到的第一件事,我的意思是。我无法声称代码真的很草率。这对我来说似乎是一个普遍不好的迹象,但作者可能有充分的理由。我的主要观点是:要求一些陌生人解释他们没有写的代码是错误的想法。相反,请使用我引用的文档正确学习该主题。
-SA
Why not asking the author of this code? No one else can be help responsible for a solution in someone else's code.
The first thing which comes to my mind would be: due to the sloppiness of the developer. I see no reasons why such method should be static. Please see: http://msdn.microsoft.com/en-us/library/byxd99hx%28v=vs.90%29.aspx[^].
Some disclaimer: when I say "first thing which comes to my mind", I mean it. I cannot claim the code is really sloppy. This is just seems to be a generally bad sign to me, but the author could have a good reason. My main point is: it's a wrong idea to ask some strangers to explain the code they did not write. Instead, please learn the topic properly using the documentation I referenced.
—SA
这篇关于为什么WebMethod在WebForm背后的代码中是静态的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文