After using javascript to click button, submit button doesn't post back
<p>Got a very weird problem that seems to be IE specific.</p>

<p>I have a form with a FileUpload control on it. However, its not possible (as far as I know) to style the button and textbox of this control individually, so what I've done is add a second button to the page, styled as I want it. Within the OnClientClick event of this button it simply clicks the "Browse" button of the FileUpload control and I select the file. I then have an "Import" button which posts back and imports the file. </p>

<p>In Chrome and Firefox this all works great. However, I've just tested it in IE, and the first time I hit the "Import" button, nothing happens, except for clearing the FileUpload control. Click the button again and it posts back, but there is now no file to upload. I've put an alert on the button on client click and this fires, but it doesn't post back.</p>

<p>If however I use the "Browse" button direct, it all works fine, so it seems to be something to do with Javascript clicking the button for me, however I cannot see why this would be, and again it seems to be IE specific. (IE9). </p>

<p>Does anyone know what might be causing this, and how I might fix it (without hopefully going back to just using the not very stylish FileUpload control)?</p>

<p>Code is as follows:</p>

<pre><code>&lt;script&gt;
    function SelectFile() {
        $("#&lt;%= uplFile.ClientID %&gt;").click();
    }
&lt;/script&gt;

&lt;asp:Button runat="server" ID="btnSelectFile" OnClientClick="SelectFile();return false;" Text="Select File" /&gt;

&lt;asp:FileUpload runat="server" ID="uplFile" Width="250" CssClass="FileUpload" OnChange="ShowSelectedFilename(this.value)" /&gt; 

&lt;asp:Button runat="server" ID="btnImport" Text="Import" OnClick="btnImport_Click" /&gt;
</code></pre>

<p>NB: I have also tried it without the "return false;" inside the OnClientClick event on the btnSelectFile button. I've also tried using document.getElementById instead of JQuery to do the click but get the same issue.</p>

<p>Any help would be much appreciated. </p>

<p>UPDATE:</p>

<p>From searching more on Google for some other errors I'm getting (e.g. "access is denied" when trying to programmatically submit the form or click the import button), it would appear this may be down to a security feature in IE, though I'm still not entirely convinced. </p>

<p>Basically, and for good reason, Microsoft don't want developers (or hackers) being able to mess with the upload control. For example, they wouldn't want a developer using javascript to, on the submitting of the form, be able to change the name of the file selected by the user to "c:\mysecretfile.txt", and therefore be able to just upload any file they like from a client. However, I'm not actually changing the filename, all I'm doing is clicking the "browse" button programmatically and from there it works as it would if the user clicked it themselves, but I expect its all to do with the same thing. </p>

<p>Unless anyone knows different?</p>
