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:
-
function redirectFormAction(iframeTargetID) {
-
var theForm = document.forms['theFormsID'];
-
theForm.target = iframeTargetID;
-
}
This method is called on the button's onclick event:
-
<input id="fup" type="file" style="width: 222px;" name="fup"/>
-
<input id="upload" type="submit" style="width: 222px;" onclick="ChangeHasOccurred(); AllowPostback('xyz'); redirectFormAction('ctl00_theiframe');" value="Preview" name="upload"/>
-
<iframe id="ctl00_theiframe" src="#" name="ctl00_theiframe">
-
</iframe>
The page form is still submitting in the window (not the iframe)...what am I doing wrong?
-Frinny