Call Server Side methods from Client Side

Hi,

How to call Server Side methods from ClientSide with results back. Earlier we were using Anthem approach but now want to use some thing with AJAX.

Thanks in Advance.

 


Regards
Sreenivas.
0
jakkulas
1/23/2008 4:47:45 PM
📁 asp.net.ajax-discussion
📃 13973 articles.
⭐ 0 followers.

💬 4 Replies
👁️‍🗨️ 364 Views

you can use the page methods of the ClientScript  control ,

please read  : http://aspalliance.com/1294_CodeSnip_Handle_Browser_Close_Event_on_the_ServerSide

 


Regards,

Anas Ghanem.


Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

0
anas
1/23/2008 5:08:04 PM

Still this has problem on refresh. Is there any other way to do it please?. Need this asap.


Regards
Sreenivas.
0
jakkulas
1/23/2008 9:32:12 PM

Just trying to put the question in details. I have button and onclick of the button I want the server side method to be executed  which returns the server time to client. Also should handle callbacks.

This approach was working fine with Anthem but doesn't work with WebUserControl. Thats why want implement AJAX feature.


Regards
Sreenivas.
0
jakkulas
1/23/2008 9:38:50 PM

Hi,

Thank you for your post!

Why not refer to official document?

Here is it:

http://www.asp.net/ajax/documentation/live/tutorials/ExposingWebServicesToAJAXTutorial.aspx, expecially the following section in that page:

Calling Static Methods in an ASP.NET Web Page

You can add static page methods to an ASP.NET page and qualify them as Web methods. You can then call these methods from script as if they were part of a Web service, but without creating a separate .asmx file. To create Web methods in a page, import the System.Web.Services namespace and add a WebMethodAttribute attribute to each static method that you want to expose.

To be able to call static page methods as Web methods, you must set the EnablePageMethods attribute of the ScriptManager control to true.

The following example shows how to call static page methods from the client script to write and read session-state values.

 
For more information about this topic, see
  1. Exposing Web Services to Client Script

  2. Calling Web Services from Client Script

 Best Regards,


Sincerely,
Jin-Yu Yin
Microsoft Online Community Support
0
Jin
1/29/2008 11:11:27 AM
Reply: