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

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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Here it is quick and dirty..

<INPUT type="file" id=file1 name=file1>
JimMorganAgviewAuthor Commented:
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">.
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>
function gObj( id )
{      var o;
      {      o = document.all(id);
      }catch( ex )
      {      o = document.getElementById[id];
      }return o;
gObj('file1').click(); //call the open file.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.