Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

find javascipt function on webpage to upload

Posted on 2012-09-10
5
Medium Priority
?
189 Views
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.

Appreciated!
0
Comment
Question by:solarissf
  • 3
  • 2
5 Comments
 

Author Comment

by:solarissf
ID: 38383113
code attached
sourcecode.htm
0
 
LVL 8

Expert Comment

by:cubaman_24
ID: 38385822
Hello:
The function you need to call is __doPostBack, as in every asp.net page to submit the form.

See this:
http://tipsdegabo.wordpress.com/2011/05/12/uso-de-__dopostback/

Best regards.
0
 

Author Comment

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

Accepted Solution

by:
cubaman_24 earned 2000 total points
ID: 38386657
Hello:
Sorry for the bad link..
This one is in English and well explained:
http://wiki.asp.net/page.aspx/1082/dopostback-function/
0
 

Author Comment

by:solarissf
ID: 38391172
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;
        theForm.submit();
    }
}

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?


Thanks!!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When I'm searching for answers on Experts Exchange, I often use Google because it's built into my browser.  To search only on Experts Exchange, I use the "site:" search operator, which can be cumbersome to type out each time I want to run a search.…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
Suggested Courses

580 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