WebBrowser control: execute file downloading ?


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.
 
Ad

Advertisements

T

Tom Shelton

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 :)
 
B

Bauhaus

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.
 
O

Onur Güzel

 > 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
 
Ad

Advertisements

B

Bauhaus

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top