By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,450 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,450 IT Pros & Developers. It's quick & easy.

Asynchronous File Upload

Expert Mod 5K+
P: 9,731
I'm attempting to upload a file asynchronously to the server by using an IFrame.

I have an Asp.NET FileUpload control on the page (which renders as an <input type="file> HTML element) and a submit button along with an IFrame.

I am attempting to redirect the form's target into the IFrame.

I have the following JavaScript function which should redirect the form's action into an Iframe on the page:
Expand|Select|Wrap|Line Numbers
  1. function redirectFormAction(iframeTargetID) {
  2.     var theForm = document.forms['theFormsID'];
  3. = iframeTargetID;
  4. }
This method is called on the button's onclick event:
Expand|Select|Wrap|Line Numbers
  1. <input id="fup" type="file" style="width: 222px;" name="fup"/>
  2. <input id="upload" type="submit" style="width: 222px;" onclick="ChangeHasOccurred(); AllowPostback('xyz'); redirectFormAction('ctl00_theiframe');" value="Preview" name="upload"/>
  3. <iframe id="ctl00_theiframe" src="#" name="ctl00_theiframe">
  4. </iframe>
The page form is still submitting in the window (not the iframe)...what am I doing wrong?

Sep 16 '09 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 15k+
P: 16,027
See the code for this. Should give some ideas.
Sep 16 '09 #2

Expert Mod 5K+
P: 9,731
I'm actually using that article (along with a few others) as a reference right now.

I didn't want to create an Object that is going to do something during the form's onsubmit either (because it should just happen when the button's clicked).

And instead of dynamically creating the iframe I've just added it to the page to keep things simple...

I didn't really see the point of creating an Object to do all of that when I could keep things much simpler..

However, I haven't tried "f.setAttribute('target', name);"
The setAttribute() method did not make any difference.
It still isn't working, the page is still isn't being submitted using the iframe.
Sep 16 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.