find javascipt function on webpage to upload

Posted on 2012-09-10
Last Modified: 2013-01-21
Hi Guys,

I have a project in winform using c#.  Using webbrowsers I navigate to a certain page deep within a website.  Eventually I get to a screen where there is an upload button.  Now I have successfully been able to click the actual button that says LOAD on the screen to load trades that way, but I was wondering if, instead of hit the button on the screen by "screen scraping", I was trying to actually call the javascript function directly from c#, instead of hitting the button.

I am attaching the sourcecode that I am reading to try and find the function I need.

From what I can piece together, so far I will need the name of the file I am uploading, maybe some kind of session code.  And to make things more complicated I know when I hit the upload button manually, the file is validated somehow.

Can someone help me translate the sourcecode to try and find what I am attempting.

Question by:solarissf

    Author Comment

    code attached
    LVL 8

    Expert Comment

    The function you need to call is __doPostBack, as in every page to submit the form.

    See this:

    Best regards.

    Author Comment

    the link is in spanish... I thought PostBack just sends info to the server, how do I specify the file I want to upload?
    LVL 8

    Accepted Solution

    Sorry for the bad link..
    This one is in English and well explained:

    Author Comment

    I've very confused.  From what I gather from your post I'm looking for this function

    var theForm = document.forms['form1'];
    if (!theForm) {
        theForm = document.form1;
    function __doPostBack(eventTarget, eventArgument) {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
            theForm.__EVENTTARGET.value = eventTarget;
            theForm.__EVENTARGUMENT.value = eventArgument;

    Open in new window

    However, if I think I am looking at the correct html item I need:
    <form name="form1" method="post" action="FileLoad.aspx?COMPANYNAME=ALL+KEYED+DATA&amp;USERID=X152169" onsubmit="javascript:return WebForm_OnSubmit();" id="form1" enctype="multipart/form-data">

    Open in new window

    This looks like it calls, WebForm_OnSubmit()

    function WebForm_OnSubmit() {
    if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
    return true;

    Open in new window

    which I don't understand.  Am I thinking about this wrong?  When does dopostback get called?


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now