I am using upload feature in my asp website. So i am using file input type. But this control add a default upload button browse and a textbox where path is shown after selecting file in Internet explorer. I don't want to show browse button etc. So what i did is add a button "Attach a File" and i have written script 'triggerFileUpload' function where i make it to click on upload control. So now when i click on "Attach a File" button browse for file windows appears and can select file to upload. But when i click on submit button the file upload control becomes reset and file is not uploaded. Error is that on clicking to submit button the file control becomes null. It happens only in internet explorer. So please help me to solve this.Below is code which can show the problem i am facing in IE.Same problem comes if i use asp:FileUpload control also. (my plan is to hide the file control and show only attach file button to user).
Code:<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> function triggerFileUpload() { document.getElementById("FileUploaddd2").click(); } </script> </head> <body> <form id="form1" runat="server"> <div> <input id="Button2" type="button" onclick="triggerFileUpload()" value="Attach a File" /> <input type="file" id="FileUploaddd2" runat="Server" /> <br /> <asp:Button ID="btnSubmit" runat="server" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Text="Submit" /> </div> </form> </body> </html>