Active Oldest Votes. Improve this answer. Whymarrh Thank you. This worked perfectly, and was exactly what I was looking for. If it does it also on IE then this is the best and simplest option to style the file input button. Mike Updated the post to fetch filename — algometrix.
Show 7 more comments. SFin 10 10 bronze badges. Shiv Kumar Shiv Kumar 9, 2 2 gold badges 34 34 silver badges 38 38 bronze badges. Community Bot 1 1 1 silver badge. Agreed, except that naming the invisible one 'ghost' looks way cooler — CristiMacovei.
It is not possible. Otherwise you may need to use Silverlight or Flash upload control. Anuraj Anuraj Which is not possible? Changing text or placing button on right or both? I upvoted this, because I think it's unfair to downvote this answer. It's basically impossible to change the text of the native file input button. The "possible solutions" are all hacks or workarounds. PeterLee - Hacks are solutions, some even follows the W3C spec. Gass Gass 2, 2 2 gold badges 9 9 silver badges 22 22 bronze badges.
Rokive Rokive 6 6 silver badges 7 7 bronze badges. Tushar Shukla Tushar Shukla 3, 2 2 gold badges 26 26 silver badges 37 37 bronze badges. Next, the replacement text box and button are added to the page:. The text box, called txtFakeText is just an ordinary text box, capable of holding simply text. Because there is no way to copy the contents of this text box back to the hidden file control, any change the user would make would cause the two HTML controls to get out of sync.
By locking the control, the only way the user can select a different file is by using the Browse button again. In this example, all that is styled is the background color of the control by setting it to red , but you can change whatever you want on this button; font, size, borders, placement, etc.
This is all that is necessary to have a styled Browse button. Your users will think they are looking at an ordinary file control, while you have now full control over the looks of the button. Source Code for this Article. Wonder where to go next? You can post a comment on this article.
I am interested in what you have to say about this article. Feel free to post any comments, remarks or questions you may have about this article.
The Talk Back feature is not meant for technical questions that are not directly related to this article. Also spam and unrealistic job offers will be deleted immediately. When you post a comment, you have to provide your name and the comment. Your e-mail address is optional and you only need to provide it if you want me to contact you.
It will not be displayed along with your comment. I got sick and tired of the comment spam I was receiving, so I have protected this page with a simple calculation exercise. This means that if you want to leave a comment, you'll need to complete the calculation before you hit the Post Comment button. If you want to object to a comment made by another visitor, be sure to contact me and I'll look into it ASAP. Don't forget to mention the page link, or the Doc ID of the document.
Unfortunately, something went wrong and your message or comments have not been submitted successfully. Active Oldest Votes. Improve this answer. Sameer Alibhai 2, 4 4 gold badges 33 33 silver badges 36 36 bronze badges.
Payam Shoeibi Payam Shoeibi 3 3 silver badges 3 3 bronze badges. I used this approach and really feel comfortable with it. But there is a main thing to change: if you apply display: none to that input, the click doesn't work, so better go with opacity: 0;. How should I send it? Chuck Chuck k 29 29 gold badges silver badges bronze badges. Pavel Pavel 2 2 silver badges 2 2 bronze badges. Peter Mortensen This will be completely unusable if JS is not available.
The HTML is invalid too. The real-world case were this would happen is extremely rare though. Also, I didn't intend for anyone to blindly copy and paste this and use it straight away, it was intended as a pointer to show one possible way of achieving the goal at hand. But hey, thanks for deterring me from posting again. Remove From My Forums. Answered by:.
Archived Forums. Getting Started with ASP. NET question on a topic that's not covered by one of the other more specific forums - ask it here. Sign in to vote.
0コメント