How to change the Text of the browse button in the FileUpload Control (System.Web.UI.WebControls)
Asked Answered
W

5

21

I want to change the Text of the browse button in the FileUpload Control (System.Web.UI.WebControls), instead of the [Browse...] text I want to use [...]

Warmonger answered 18/9, 2008 at 16:43 Comment(0)
A
9

This isn't technically possible for security purposes, so the user cannot be misled.

However, there are a couple of workarounds, although these require working with the raw HTML rather than the .NET server control - take a look at http://www.quirksmode.org/dom/inputfile.html for one example.

Agentival answered 18/9, 2008 at 16:48 Comment(0)
E
12

This is old, but wanted to offer another solution. You can use jQuery on a standard HTML hyperlink and fire asp:FileUpload on click of the HREF. Just hide the asp:FileUpload at design and doctor the href any way you'd like.

Link

<a href="#" id="lnkAttachSOW">Attach File</a>

asp:FileUpload

<asp:FileUpload ID="fuSOW" runat="server" style="visibility:hidden;"/>

Then the jQuery:

$("#lnkAttachSOW").click(function () {
    $("#fuSOW").click();
});
Elevated answered 11/4, 2012 at 19:43 Comment(1)
Tried this. It opens the file dialog box, but it does not save the file in the FileUpload control, so FileUpload.HasFile is always false.Pelops
A
9

This isn't technically possible for security purposes, so the user cannot be misled.

However, there are a couple of workarounds, although these require working with the raw HTML rather than the .NET server control - take a look at http://www.quirksmode.org/dom/inputfile.html for one example.

Agentival answered 18/9, 2008 at 16:48 Comment(0)
R
2

This was how I did it in .NET using AsynchFileUpload and JavaScript...

<asp:Button ID="bUploadPicture" runat="server" Text="Upload Picture"
    OnClientClick="document.getElementById('<%=tFileUpload1.ClientID%>')
        .click();return (false);" />

<div style="display:none;visibility:hidden;">
     <asp:AsyncFileUpload ID="tFileUpload1" runat="server" 
        OnUploadedComplete="tFileUpload1_UploadedComplete" />
</div>
Roxannroxanna answered 15/11, 2014 at 1:52 Comment(0)
F
0

Some third party tools provide this option. For example, we use the Telerik Upload control:

Changing the text of the Browse/select button

Example of Rad Upload control

Farmhand answered 30/4, 2010 at 15:35 Comment(0)
T
0

You could use another button and java script to trigger upload browse button, Check this cute and simple solution How to change Text in FileUpload control

Hope this help.

Tyrannize answered 24/7, 2013 at 14:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.