Question Web Browser Control - javascript submit

mla_ca520

Member
Joined
Jul 30, 2009
Messages
8
Location
New Mexico
Programming Experience
Beginner
Hi Y'All,
I have the following html file on my local computer.
I would like to embed all of this into a VB 2008 browser
so that when I launch the app, it will automatically submit the form
with the xml command rather than having to open the html page
Additionally, the url that this goes to requires windows authentication, which
takes place in a windows popup dialogue. How can I automatically populate
that dialogue with user name and password?

Any help would be greatly appreciated. thanks,
MA
VB.NET:
<HTML>
<HEAD>
<TITLE>Test Form</TITLE>
</HEAD>
 <SCRIPT LANGUAGE="JavaScript">
 function fnSubmit() {
   window.document.XMLFORM.submit();
   return;
 }
 </SCRIPT>
<BODY LANGUAGE="javascript" onload="return fnSubmit()">
<FORM NAME="XMLFORM" METHOD="POST" ACTION="http://web-address">
XML Request:<BR>
<TEXTAREA NAME="XMLREQUEST" ROWS=10 COLS=60>
<Request>
<PingXML>
<Data>Test Ping</Data>
</PingXML>
</Request></TEXTAREA><br>
</BODY></HTML>
 
Answered!

Answered my own question:

VB.NET:
WebBrowser1.DocumentText = _ 
"<HTML><HEAD><TITLE>Test Form</TITLE></HEAD> <SCRIPT LANGUAGE=""JavaScript""> function fnSubmit() {" & _ 
" window.document.XMLFORM.submit(); return; }" & _ 
" </SCRIPT><BODY LANGUAGE=""javascript"" onload=""return fnSubmit()"">" & _ 
"<FORM NAME=""XMLFORM"" METHOD=""POST"" ACTION=""" & strURL & """>" & _ 
"XML Request:<BR><TEXTAREA NAME=""XMLREQUEST"" ROWS=10 COLS=80><Request><PingXML>" & _ 
"<Data>Test Ping</Data></PingXML></Request></TEXTAREA><br></BODY></HTML>"

this does the trick!
to search the results of the page:

VB.NET:
If WebBrowser1.DocumentText.Contains("XML ping successful (replace with your desired results)") Then 
(actions to take if ping successful) 
else 
(actions to take if ping unsuccesful) 
end if
 
Back
Top