Need to change Browse button text

Discussion in 'ASP .Net Web Controls' started by Christopher Attard, Feb 5, 2004.

  1. Hello,
    I'm using an <input type=file> control in an asp.net page and I need to change the text of the "Browse..." button cos the page needs to be multi-lingual.

    Any ideas or suggestions?

    Thanks,
    Chris
     
    Christopher Attard, Feb 5, 2004
    #1
    1. Advertising

  2. hi Chris,
    You cannot reflect the style properties set on the INPUT element or change
    the text on the Browse button, but there is a way to get most of the
    functionality you need. First, you'll need to actually use a file upload
    element for both its browsing and uploading abilities. Next you'll have to
    add your own button and text field to the page. Then, to tie them together,
    you'll have the button's onClick event trigger the click method of the file
    upload element and the onChange event of the file upload element set the
    value of the text field. Then, you can customize the appearance of the
    button and text field as usual. Here's a sample:


    <INPUT TYPE="file" ID="filUpload" STYLE="display:none"
    onChange="txtFilename.value = this.value;">
    <asp:input runat="server" ID="txtFilename"
    STYLE="FONT-FAMILY:Tahoma;FONT-SIZE:9pt"
    SIZE="25" DISABLED>
    <INPUT TYPE="button" ID="btnBrowse" STYLE="FONT-FAMILY:Tahoma;FONT-SIZE:9pt;
    BACKGROUND-COLOR:peachpuff" onClick="filUpload.click()"
    VALUE="Choose a File">


    However theres a catch. Because of the file upload element's security
    restrictions, this workaround does not allow the user to change the location
    of the file to be uploaded simply by editing the value of the text field
    which is why its DISABLED attribute is set.


    "Christopher Attard" <> wrote in message
    news:...
    > Hello,
    > I'm using an <input type=file> control in an asp.net page and I

    need to change the text of the "Browse..." button cos the page needs to be
    multi-lingual.
    >
    > Any ideas or suggestions?
    >
    > Thanks,
    > Chris
     
    Alessandro Zifiglio, Feb 5, 2004
    #2
    1. Advertising

  3. Ok it works as explained...thanks very much for your help

    Chris
     
    Christopher Attard, Feb 5, 2004
    #3
  4. your welcome chris. I had actually forgotten to clean up and left an un
    wanted <asp:input tag in there with runat="server" when i wanted to display
    a normal html input element for the sample, but you got it working still,
    great ;)

    for everybody else viewing this post here is a cleanup :

    <input type="file" id="filupload" style="display:none"
    onchange="txtfilename.value = this.value;" />
    <input type="text" id="txtfilename" style="font-family:tahoma;font-size:9pt"
    size="25" disabled="false" />
    <input type="button" id="btnbrowse" style="font-family:tahoma;font-size:9pt;
    background-color:peachpuff" onclick="filupload.click()"
    value="choose a file" />



    "Christopher Attard" <> wrote in message
    news:...
    > Ok it works as explained...thanks very much for your help.
    >
    > Chris
     
    Alessandro Zifiglio, Feb 5, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Olivier Verdin
    Replies:
    4
    Views:
    22,502
  2. bsm
    Replies:
    0
    Views:
    1,325
  3. bsm
    Replies:
    3
    Views:
    290
  4. Replies:
    0
    Views:
    222
  5. Replies:
    8
    Views:
    497
Loading...

Share This Page