I have the following below code in C# at the client in a silverlight application, to post some data to IHttpHandler as the server
var newForm = doc.CreateElement("form");
newForm.SetAttribute("action", somUri);
newForm.SetAttribute("method", "post");
body.AppendChild(newForm);
newForm.AppendChild(CreateInputElement(doc, "data", someData));
newForm.AppendChild(CreateInputElement(doc, "filename", filename));
newForm.AppendChild(CreateInputElement(doc, "contentType", contentType));
var obj = newForm.Invoke("submit");
The problem is I can not be sure when the data submitted to the IHttpHandler at the server is actually completed.
newForm.Invoke("submit"); above seems to make the submit call and not block even though the server has not finished its work.
Is there some way to register the callback so that I know that processing at the server has been completed?
Thanks
As far as I know you can not have callback kind of thing for form POST method in silverlight.
I have another alternative for you. Call a javascript method from silverlight C# code and make post ajax request there. Then you will have callback handler of success as well as Error callback use it to right your business logic.
You can refer this link for how to call javascritpt from silverlight C# code and silverlight C# method from javascript.
Be aware of
System.Windows.Browser.HtmlPage.Window.Invoke
it might become security issue.I hope that is helpful.