web service call server side

Hi Experts,

I have a simple <input id="mybutton" runat="server" onserverclick="callwebservice" type="button"/>
I would need example in cs file to call my asmx web service and get result in the same
cs class.

I am working in 4.0 C# framework.

Thanks.
LVL 1
fpoyavoAsked:
Who is Participating?
 
Srihari03Connect With a Mentor Commented:
Sample Button .aspx page:

 <div>
        <input id="mybutton" value="CallWebService" runat="server" onserverclick="callwebservice" type="button"/>
    </div>

Snippet in .cs file:


protected void callwebservice(object sender, EventArgs e)
        {
            ExpertSamples.SampleWS sampleWS = new SampleWS();
            Response.Write(sampleWS.HelloWorld());  
        }
0
 
Monica PSoftware DeveloperCommented:
Firstly create an Object to access the your asmx file main class

Using the Object reference the webmethod in your asmx file.

Read the response and based on that make your logic works
0
 
fpoyavoAuthor Commented:
May you provide working example?
0
All Courses

From novice to tech pro — start learning today.