Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to call web service on page load in C# asp.net...?
please help me....
Posted
Comments
MuhammadUSman1 2-Oct-13 3:10am    
Please paste code what you are trying. and what is issue?
MuhammadUSman1 2-Oct-13 3:13am    
Check Solution i added.

suppose this is you web service method

C#
[WebMethod]
         public string WelcomeUser(String _userName)
         {
             return "You are Welcome : " + _userName;
         }


and you want to use that service in your page load of a page. IN that case you simply need to create the object of the service proxy and use that object to access the wen method like this:

C#
HelloWorld.Service _objHello = new HelloWorld.Service();
      _objHello.WelcomeUser("Guest");


Hope this help

-SG
 
Share this answer
 
Simply put your calling code in the Page_Load method in your code behind:
HTML
protected void Page_Load(object sender, EventArgs e)
{
    // make sure this is not a postBack event..
    if (!Page.IsPostBack)
    {
            webService.myMethod();
    }
}
 
Share this answer
 
v2

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