Click here to Skip to main content
15,502,616 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys

Is there a way to put on some style in asp.net FileUpload button, only the button not the whole control using classes from bootstrap?
Posted
Updated 1-Sep-20 20:26pm

Lots of suggestions here: http://stackoverflow.com/questions/11235206/twitter-bootstrap-form-file-element-upload-button[^]

I've used this one[^], and it works fairly well in most browsers.
 
Share this answer
 
Comments
Anele Ngqandu 14-Aug-14 10:56am    
The project uses this control <asp:FileUpload CssClass="btn btn-warning" ID="fileuploadimages" runat="server" />
Richard Deeming 14-Aug-14 10:57am    
Almost all of the answers in the SO thread will work with that control. The Bootstrap Filestyle script certainly does - I've used it myself.
bobishkindaguy 6-Jul-17 17:07pm    
The stackoverflow reference above has everything to style the controls and browse for the file, but I can't see how to get the resulting path into asp.net so I can upload the file.
Richard Deeming 6-Jul-17 17:25pm    
You don't. You submit the form containing the file upload, and get an HttpPostedFile on the server. You then either save the file somewhere, or read and process the raw bytes.

The path of the selected file will be local to the client. There's nothing you could do with it on the server.
bobishkindaguy 6-Jul-17 17:48pm    
I'm new to asp.net. So I need just a bit more help.
I got it browsing fine, and then it displays the filename - nice for the user to confirm that's the one they want to process.
So then I put a "Submit" button on the page, and the user clicks that which gets me to the code behind.
You're saying the submitted page has the actual file "embedded" in it, and all I have to do is get that using HttpPostedFile and save it on the server side, right?
I don't see "Page.HttpPostedFile" or "Session.HttpPostedFile", would you mind posting a code snippet to show how to get the file contents into a variable? My files will be text, so I would probably be carefully converting the object to a string.
I've looked at HttpPostedFile Class in msdn, but there is no code example.
Use Asp.Net File Upload control.
<asp:fileupload runat="server" id="fileUpload">

To Style it use the below css.


input[type=file]::-webkit-file-upload-button {
color: #ffffff;
border: none;
padding-top: 5px;
background-image: linear-gradient(to right, #051937, #004d7a, #008793, #00bf72, #a8eb12);
border-radius: 4px;
height: 30px;
width: 400px
}

 
Share this answer
 
Comments
CHill60 2-Sep-20 8:26am    
You've added nothing new to this old thread

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