I am using a C# WebBrowser
to navigate to a page.
After navigate to that page I extract some link from its source code and then start to navigate to those sub_links in a loop which I get from its parent url.
On every sub_links there is a link which is look like:
<a onclick="sysMT('SYSext.Sup_Filetype','type','SYSext.Sup_Filename','Filename.exe','SYSext.Sup_Referer','http://abc.com');"
id="ctl00_UCDownloadFile1_Accept"
href="javascript:__doPostBack('ctl00$UCDownloadFile1$Accept','')">Accept</a>
the id of a button is "ctl00_UCDownloadFile1_Accept"
is same in all its sub_links.
When I click on above link manually a file start to download.
I want to "click"
on above button using c# code.
I am able to click
on above button using this code on webBrowser1_DocumentCompleted event
:
HtmlElement elementById = webBrowser1.Document.GetElementById("ctl00_UCDownloadFile1_Accept");
if (elementById != null)
{
elementById.InvokeMember("click");
Application.DoEvents();
}
But a script error message box appear saying
"An error has occured in the script on this page.
Error: The value of the property 'sysMT' is null or undefined, not a Function object.
Do you want to continue running script on this page?
Yes NO"
Not able to understand what I am missing in this. Did Parent url make some cookie which helps to download the file? Don't know how to download that file and also download file link.
I am new to C# WebBrowser.
Update
I am able to remove a script error message box using
webBrowser2.ScriptErrorsSuppressed = true;
But not able to download all file which are their in sub links i.e.
If I get 3 links from a parent url, then I navigate to first link, click on Accept link and then a box appear asking for a action to RUN SAVE CANCEL.
But I get this box only for third (last) link.
How to overcome with this problem, I want to download all file from each links without any prompt which asking for RUN SAVE CANCEL.
Directly SAVE
a file.