Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
4.67/5 (2 votes)
See more:
Hello friends

I have following scenario.

I have one default.aspx page where I put following HTML code.

HTML
<iframe id="iframeUploadLogo" src="Default2.aspx"></iframe>


In default2.aspx page, I have put following code.

ASP.NET
<form id="form1"  runat="server" name="Form1">
    <a href="javascript:;"  önclick="browseFile();">Upload Logo</a>
    <div style="display:none;">
        <asp:FileUpload ID="FileUploadControl" runat="server" onchange="onChangeFile(this);" />
    </div>
    </form>


And javascript function:

JavaScript
function onChangeFile(o) {

            var file = $(o).val().toLowerCase();
            if (file.indexOf(".png") == -1 && file.indexOf(".jpg") == -1 && file.indexOf(".jpeg") == -1 && file.indexOf(".gif") == -1) {
                alert("please upload image file only.");
            } else {
                
                $("#form1").submit();
            }
        }
        function browseFile() {
            var o = $("#FileUploadControl");
            o.click();
        }


When I click on link button to upload logo, then window is open and I choose image file, so after that form is not submitted which is working fine in other browsers, I have issue only in IE browser.

If I remove link button, and use file upload control directly then form is submitted, If I use link button to fire File Upload control onClick event then form is not submiited, strange!

Any solution?

Thanks
Imrankhan
Posted
Updated 12-Sep-13 2:49am
v2
Comments
Sanjeev Alamuri 12-Sep-13 8:48am    
try this once!!!

$("#form1")[0].submit();
or else
document.forms[0].submit();
Hi Imran,

First of all, very well explained and proper code blocks pasted.

So, I voted 5+.

Coming to the problem, I will try this at my end and let you know my findings.

Thanks,
Tadit
Imran Khan Pathan 23-Sep-13 7:34am    
Thanks Tadit Dash,

Is there any finding your side?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900