Hi is there a way to submit a form WITHOUT clicking the submit button?
Keep in mind this is inside the webBrowser1 control in C# . So if i click a button in my C# application it should automatically submit the form.
Hi is there a way to submit a form WITHOUT clicking the submit button?
Keep in mind this is inside the webBrowser1 control in C# . So if i click a button in my C# application it should automatically submit the form.
You can inject Javascript code that submits the form to the page:
// Do this on form load.
HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0];
HtmlElement scriptEl = webBrowser1.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement;
element.text = "function submitForm() { document.getElementById('formId').submit(); }";
head.AppendChild(scriptEl);
Then invoke it on button click:
// In button click handler
webBrowser1.Document.InvokeScript("submitForm");
Another Way:
Webbrowser1.navigate("javascript:document.getElementById('FormId').submit();")
There are many ways to do it, if this code not working I'll bring you more examples.