[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How can I send a click event to a HTML filefield control

Posted on 2006-04-11
4
Medium Priority
?
325 Views
Last Modified: 2008-02-01
I have an ASPX from that is used for maintaining data in a SQL table of job requests.
Some of the requests will have files attached.
Currently, I am using a 2nd page to find and attach files.
This page has a HTML filefield control and an asp  button with code behind to insert the selected file into the database.

I would like to reduce mouse clicks by having the form load event send a click event to the filefield control so that the file browser control is displayed without the need to click the filefield control's button.
0
Comment
Question by:JimMorganAgview
  • 2
4 Comments
 
LVL 18

Expert Comment

by:armoghan
ID: 16435554
Hi JimMorganAgview,
Use javascript to do such stuff. or for more detail ask the question in ASP.NET section of EE

Cheers!
0
 
LVL 11

Expert Comment

by:coopzz
ID: 16435769
Here it is quick and dirty..

<INPUT type="file" id=file1 name=file1>
<script>file1.click();</script>
0
 

Author Comment

by:JimMorganAgview
ID: 16442330
I have tried the script suggested by coopzz and get a runtime error
"Microsoft JScript runtime error: file1 is undefined".
This occurs, even after I change to <INPUT type="file" id="file1" name="file1">.
0
 
LVL 11

Accepted Solution

by:
coopzz earned 2000 total points
ID: 16443684
it's most probably just the browser version your in... howevery you normally link up your buttons in your code is what you need to do.

but what your after is the .click(); on the button object. once you have the reference it works fine..

fyi: it works fine just that code in a html file in IE 6 sp 2

one of the ways i use is a generic getObj function like so.

<INPUT type="file" id=file1 name=file1>
<script>
function gObj( id )
{      var o;
      try
      {      o = document.all(id);
      }catch( ex )
      {      o = document.getElementById[id];
      }return o;
}
gObj('file1').click(); //call the open file.

</script>

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

830 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