void CallBackJSONAddRequest(IAsyncResult ar)
{
WebRequest req = (WebRequest)ar.AsyncState;
Stream reqStream = req.EndGetRequestStream(ar);
reqStream.Close();
req.BeginGetResponse(CallBackJSONResponse, req);
}
void CallBackJSONResponse(IAsyncResult ar)
{
try
{
WebRequest req = (WebRequest)ar.AsyncState;
WebResponse res = req.EndGetResponse(ar);
Stream strResult = res.GetResponseStream();
strResult.Close();
res.Close();
}
catch (Exception ex)
{
string s = ex.Message;
}
}
private void button1_Click(object sender, EventArgs e)
{
string uploadUrl = "http://localhost:7794/GetEmployees.svc/CreateEmployee/" + textBox1.Text + "/" + textBox2.Text + "/" + textBox3.Text;
WebRequest addRequest = WebRequest.Create(uploadUrl);
addRequest.Method = "POST";
addRequest.BeginGetRequestStream(CallBackJSONAddRequest, addRequest);
label1.Text = "Employee" + textBox1.Text + "Inserted Successfuly";
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
}