WebBrowser control: execute file downloading ?

  • Thread starter Thread starter Bauhaus
  • Start date Start date
B

Bauhaus

I have a html page with this code:

<html>
<head>
<title></title>
<script language="JavaScript" type="text/JavaScript">
<!-- AUTO-SUBMIT FORM
function submit_form(){
document.myform.submit();
}
// - End of JavaScript - -->
</script>
</head>
<body onload="submit_form();">
<form name="myform" method="post"
action="http://binsearch.info/fcgi/nzb.fcgi">
<input name="action" value="nzb">
<input value="NZB" type="submit">
</form>
</body>
</html>

When I load the page in IE or Firefox, it asks to open/save a file, becos of
the javascript.
I want this same behaviour in my VB program, so I created a webbrowser
control and use the html page as url.
Unfortunately, it doesnt ask to open/save the file, I have to push the
submit button first.
How can I make it immediately save the file without pushing the button ?

And is it necessary to use a webbrowser control ? Becos I dont want any page
to be displayed, I only want to execute the code of the page, meaning
downloading the file automatically.
 
I have a html page with this code:

<html>
<head>
<title></title>
<script language="JavaScript" type="text/JavaScript">
<!-- AUTO-SUBMIT FORM
function submit_form(){
document.myform.submit();
}
// - End of JavaScript - -->
</script>
</head>
<body onload="submit_form();">
<form name="myform" method="post"
action="http://binsearch.info/fcgi/nzb.fcgi">
<input name="action" value="nzb">
<input value="NZB" type="submit">
</form>
</body>
</html>

When I load the page in IE or Firefox, it asks to open/save a file, becos of
the javascript.
I want this same behaviour in my VB program, so I created a webbrowser
control and use the html page as url.
Unfortunately, it doesnt ask to open/save the file, I have to push the
submit button first.
How can I make it immediately save the file without pushing the button ?

And is it necessary to use a webbrowser control ? Becos I dont want any page
to be displayed, I only want to execute the code of the page, meaning
downloading the file automatically.

System.Net.HttpWebRequest/HttpWebResponse

or

System.Net.WebClient.DownloadFile

Oh, and I think there is some My thingy as well :)
 
System.Net.HttpWebRequest/HttpWebResponse
or

System.Net.WebClient.DownloadFile

Oh, and I think there is some My thingy as well :)

Already tried that, but then the html page is downloaded.
What I want is executing the code within the html page, which downloads a
file.
 
 > System.Net.HttpWebRequest/HttpWebResponse




Already tried that, but then the html page is downloaded.
What I want is executing the code within the html page, which downloads a
file.

Hi,
To press a button programatically on your page to execute required
javascript, you can consider using:
InvokeMember method, which can be accessible using a Webbrowser, and
if you do not want your webbrowser to be shown, you can place it then
try to hide it.

Untested, you can check this out:
http://msdn.microsoft.com/en-us/library/0t9yb2z4.aspx

WebBrowser1.Document.GetElementById("element_id_here").InvokeMember
("method_name_here")

HTH,

Onur Guzel
 
Hi,
To press a button programatically on your page to execute required
javascript, you can consider using:
InvokeMember method, which can be accessible using a Webbrowser, and
if you do not want your webbrowser to be shown, you can place it then
try to hide it.

Untested, you can check this out:
http://msdn.microsoft.com/en-us/library/0t9yb2z4.aspx

WebBrowser1.Document.GetElementById("element_id_here").InvokeMember
("method_name_here")

HTH,

Onur Guzel

Thanks, tried InvokeScript and that worked.
 
Back
Top