Click here to Skip to main content
15,904,817 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have designed a Fileupload control inside a button. It is woking finr in Google Chrome and file upload and save everything work perfectly.

But when I want to browse any file in Mozila Firefox the file upload control does not work.

Here is my code.

ASP.NET
<td class="TableSix">
                                                <button type="button" class="TableThree" style="position: relative;">
                                                    <asp:FileUpload ID="btnGovt_Id_Upload" runat="server" placeholder="BROWSE" class="TableThree" Style="width: 100%; opacity: 0.0; color: #c4c4c4; position: absolute;" />
                                                    BROWSE</button></td>





Thanks

Bigyan Sahoo

What I have tried:

When I remove the button then it is working fine but when I use the button for style then its not working in Firefox.
Posted
Updated 23-Aug-16 2:21am
Comments
Tushar sangani 23-Aug-16 5:54am    
Why are you use button outside of File upload control??
bigyan sahoo 23-Aug-16 6:20am    
I want to design the file upload control look like as a button with text as BROWSE.
F-ES Sitecore 23-Aug-16 5:59am    
It's not the fileupload that isn't working in Firefox, it is your attempts to style it and embed it that isn't working so your title is a little misleading.
bigyan sahoo 23-Aug-16 6:17am    
I want to design the file upload control look like as a button with text as BROWSE.

When you nest the control inside a <button>, that button receives the click, and does not pass it on to the invisible file upload control.

Try nesting it inside a <label> instead:
Whipping File Inputs Into Shape with Bootstrap 3 · A Beautiful Site[^]
HTML
<label class="btn btn-default btn-file">
    Browse <input type="file" style="display: none;">
</label>

CSS
.btn-file {
    position: relative;
    overflow: hidden;
}
.btn-file input[type=file] {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 100%;
    min-height: 100%;
    font-size: 100px;
    text-align: right;
    filter: alpha(opacity=0);
    opacity: 0;
    outline: none;
    background: white;
    cursor: inherit;
    display: block;
}


Alternatively, use a pre-built plugin - for example: Bootstrap File Input[^]
 
Share this answer
 
v2
Quote:
I want to design the file upload control look like as a button with text as BROWSE.
Then you have to use fake controls.

So, hide the actual file upload control and on the other button click event, just click the file upload control dynamically using JavaScript/jQuery.
 
Share this answer
 

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



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