Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear,

I have created web services in asp.net to get the user and i also checked in asp.net web form its working perfectly.

below is the code on button click

VB
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim abc As New ServiceReference1.WebService1SoapClient
    TextBox2.Text = abc.GetUser(TextBox1.Text)

End Sub


Now i want to same services in windows phone i already add a reference in windows phone and wrote a below code but how i fetch in TextBox2.Text

below is the code, i want to achieve same code as above

VB
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
    Dim abc As New ServiceReference1.WebService1SoapClient
    abc.GetUserAsync(TextBox1.Text)

End Sub


Thanks
Basit.
Posted

1 solution

There should be a callback delegate.
AddHandler service.GetUserComplete AddressOf GetUserCompleted 

Then add a method that handles this callback.
VB
Private Sub GetUserCompleted(sender As Object, e As ServiceReference1.GetUserCompleteEventArgs)
  'Access e.Results here
End Sub
 
Share this answer
 
Comments
basitsar 29-Apr-15 4:16am    
Many thanks, Please can you tell me more details where should and how to add the handler.

Below is my full page code

Partial Public Class Page1
Inherits PhoneApplicationPage

Public Sub New()
InitializeComponent()
End Sub

Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim abc As New ServiceReference1.WebService1SoapClient

abc.GetUserAsync(TextBox1.Text)


End Sub

Private Sub GetUserCompleted(sender As Object, e As ServiceReference1.GetUserCompletedEventArgs)
'Access e.Results here

End Sub
End Class
Abhinav S 29-Apr-15 4:39am    
Add the handler inside Button1_click.
basitsar 29-Apr-15 4:38am    
Please tell me how to add handler in my code

Partial Public Class Page1
Inherits PhoneApplicationPage

Public Sub New()
InitializeComponent()
End Sub

Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim abc As New ServiceReference1.WebService1SoapClient
'//how to add handler here
abc.GetUserAsync(TextBox1.Text)

End Sub

Private Sub GetUserCompleted(sender As Object, e As ServiceReference1.GetUserCompletedEventArgs)
'Access e.Results here
TextBox2.Text = e.Result.ToString
End Sub
End Class

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