Click here to Skip to main content
16,012,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am calling a wcf service asynchronously its returning a srting value and i want to bind this to my text box txtEmpName.My problem is that wcf service is returning correct value in asyncallback but its not getting binded to textbox ? What modification i have to do in asyncallback ?

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.ServiceModel;
using System.Threading;


public partial class AsynchronousCall : System.Web.UI.Page
{
    string EmpName = null;
    
    protected void Page_Load(object sender, EventArgs e)
    {
         
       
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int EmpNo = Convert.ToInt32(DropDownList1.SelectedValue);
         makeAysnCall(EmpNo);  
       
    }


    public void makeAysnCall (int EmpNo)
    {
    
     ServiceReference1.EmpNameServiceClient client = new ServiceReference1.EmpNameServiceClient();
        EndpointAddress endpointAddress = client.Endpoint.Address;
        BasicHttpBinding basicHttpBinding = new BasicHttpBinding();

        ServiceReference1.IEmpNameService iEmpNameService
      = new ChannelFactory<servicereference1.iempnameservice>(basicHttpBinding,  endpointAddress).CreateChannel();
        AsyncCallback asynCallBack = delegate(IAsyncResult result)
        {
             EmpName = iEmpNameService.EndgetEmpName(result);
             txtEmpName.Text = EmpName;
                                  
        };
        
        iEmpNameService.BegingetEmpName(EmpNo, asynCallBack, iEmpNameService);       
      }
}</servicereference1.iempnameservice>
Posted
Updated 6-Sep-11 21:27pm
v2
Comments
Prerak Patel 7-Sep-11 3:27am    
Use code block for code segments.

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