Click here to Skip to main content
16,010,334 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public void disp()
        {
            if (txtbox.Text != "")
            {
                txtbox.Text = "Hello world";
            }
        }
[WebMethod]
        public static void Disp()
        {
            
        }
Posted
Comments
ZurdoDev 23-Apr-13 7:06am    
If you want to call webservice onblur of textbox use jquery's .ajax method.

Raj Wrote:
how to call instance method in web method?

Since webservice is a static method, it can only call other static methods or new objects.
WebMethod:
C#
[WebMethod]
public static void ResetDate(DateTime TheNewDate)
{
    var thisPage = new Test();
    thisPage.LoadCallHistory("args");
}

Class:
C#
Class Test
{
     public void LoadCallHistory(string args)
     {
         //Do your work here
     }
}

Or
WebMethod:
C#
[WebMethod]
public static void Disp()
{
    disp();//call the static function here
}

Class:
C#
public static void disp()
{
    if (txtbox.Text != "")
    {
        txtbox.Text = "Hello world";
    }
}

Raj Wrote:
how to call a web method using Javascript?

Check Calling Web Services from HTML Pages using JavaScript[^]

Hope it helps!

--Amit
 
Share this answer
 
v3
Have a look at the following articles:
1. WebService call[^]
2. PageMethod[^]

You need to tie the onblur event with the callback/ajax call and talk to the method.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900