Invoking ASP.NET codebehind method from JavaScript

后端 未结 4 897
悲&欢浪女
悲&欢浪女 2021-01-29 05:25

Can someone please tell me how I can invoke a ASP.NET codebehind method from client-side JavaScript?

Thanks

4条回答
  •  星月不相逢
    2021-01-29 05:32

    Use an update panel control is the easiest way, but you can post the page to the server and get the result using Sys.Net.WebRequest: http://msdn.microsoft.com/en-us/library/bb310979.aspx.

    That's a lot harder because you have to manually update the response in the page, wipe out the old content, parse the result, and inject the new content. The typical way it is done is to use a web service and call Sys.Net.WebServiceProxy.invoke method: http://msdn.microsoft.com/en-us/library/bb383814.aspx. This can call a web service within the page (page methods) or a separate ASMX or WCF web service.

    HTH.

提交回复
热议问题