Use a Button like a FileUpload in ASP.NET
<p>I have this situation:</p>

<p><a href="https://i.stack.imgur.com/ujRWu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ujRWu.png" alt="enter image description here"></a></p>

<p>Two normal ASP.NET controls.
But I want to hide the FileUpload control, and remain with the only Button.</p>

<p>Something so trivial is causing me more problems than expected.This is my implementation:</p>

<p><strong>ASPX</strong>:</p>

<pre><code>&lt;asp:FileUpload ID="FileUpload1" runat="server" /&gt;

&lt;asp:Button ID="UploadButton" runat="server" Text="Carica Documento" OnClientClick="showBrowseDialog();" /&gt;

&lt;asp:Button runat="server" ID="hideButton" Text="" style="display:none;" OnClick="UploadButton_Click" /&gt;

&lt;script type="text/javascript" language="javascript"&gt;
    function showBrowseDialog() {
        var fileuploadctrl = document.getElementById('&lt;%= FileUpload1.ClientID %&gt;');
        fileuploadctrl.click();

        var btn = document.getElementById('&lt;%= hideButton.ClientID %&gt;');
        btn.click();
    }
&lt;/script&gt;
</code></pre>

<p><strong>C#</strong>:</p>

<pre><code>protected void UploadButton_Click(object sender, EventArgs e)
{
    if (FileUpload1.HasFile)
    {
        try
        {
            string address = Server.MapPath("") + "\\" + FileUpload1.FileName;
            FileUpload1.SaveAs(address);
            //...
        }
        catch (Exception) { }
    }
</code></pre>