In previous posts I explained How to Call Asp.net Page methods in jQuery, JavaScript restrict to enter only numbers, JavaScript Redirect to another page after some time delay, JavaScript Set Default home page in browsers and many articles relating to JavaScript, Asp.net. Now I will explain how to call server side methods or functions from JavaScript in asp.net.
|
C# Code
using System;
using System.Web.Services;
|
[WebMethod]
public static string GetCurrentDate(string
name)
{
return "Hi "
+ name + Environment.NewLine + "Welcome to Aspdotnet-Suresh.com ";
}
|
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|
|

Subscribe by RSS
Subscribe by Email
4 comments :
hi suresh..have a doubt..
why have u made "GetCurrentDate" a [web method]??
cant it be a normal method? reply
bhatimohit@gmail.com
best example
yes i too have a same doubt that can't we call a normal method?
I dont want it as webmethod. Can it be done?
How to use external javascript file in asp.net.