Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7586005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:19:00+00:00 2026-05-30T19:19:00+00:00

In a ASP.NET C# website I have an input that uploads a file to

  • 0

In a ASP.NET C# website I have an input that uploads a file to my server. To overcome the issue of not being able to style an input of the type=file I have created a styled div that looks like the input but actually just relays the message to the actual input which has display: none to be invisible.

My Problem: Relaying the message isn’t working, ie, when I relay the click message to the actual input the file is never uploaded(nothing happens). I know the button works because if I click the actual input it uploads the file sucessfully.

Is there some ASP.NET security stopping me from being able to do this? Whats going wrong? How can I acheive what I am trying to do:
Have a style input where type=file(not a boring browse button) & relay the click to the actual input?

My actual input which works:

<input id="fileUpload" type="file" Runat="server" NAME="fileUpload"/>
<asp:button id="btnSave" OnClick="bt1Clicked" 
                runat="server" Text="Upload File"></asp:button>
<asp:label id="lblMessage" runat="server"></asp:label> 

My styled button:

<a onclick="$(\'btnSave\').click(); return false;" href="#">test</a>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:19:01+00:00Added an answer on May 30, 2026 at 7:19 pm

    Not sure what your aiming at but this should work

    <a onclick="$('<%= btnSave.ClientID %>').click(); return false;"
                                                         href="#">test</a>
    

    Why? Because by default, asp.net gives controls its own id, which is defined by ClientIdMode. See also System.Web.UI.Control.ClientID

    In my humble opinion, this would be a neater solution:

    <a id="btnRelay" href="#">test</a>
    

    Hook it up with JQuery separately, so your code isn’t mangled with your html.

    $('btnRelay').click(function(event){
        event.preventDefault();
        $('<%= btnSave.ClientID %>').click()
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a website in ASP.NET 3.5 that takes some input in text
In my asp.net-mvc website I have a field that usually has a string (from
I currently have an asp.net website hosted on two web servers that sit behind
I have a ASP.Net website that is failing on AJAX postbacks (both with ASP.Net
I have an asp.net website that allows the user to download largish files -
We have a large ASP.Net website that has a single css stylesheet which is
My ASP.NET MVC 3 website has code on the server side that checks for
I have an ASP.NET website where i have implemented page level caching using the
ASP.NET newbie here I have coded up an ASP.NET website and running on win'08
I have an ASP.NET website and when I press F5 it automatically attaches to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.