Click here to Skip to main content
13,254,754 members (49,499 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi,

I would like to know how to achieve the following:

Show (hidden with code behind on page load) an ASP Button, when the FileUpload ASP control has a file selected.

aspx

<asp:FileUpload ID="FileUpload1" runat="server" onchange="showButton()"/>
                       <p><asp:Button ID="Button1" runat="server"  Text="Upload File" />&nbsp;</p>



When FileUpload1 has a file selected the onchange should fire
(Button 1 stays hidden and does not show)

Javascript:

<script type ="text/javascript" >
          function showButton() {
              document.getElementById('<%=Button1.ClientID%>').style.visibility = "visible";
          }
</script>


but this does not work.

Please let me know what I am doing wrong.

(should Button1.Visible=true; be used in codebehind instead, if so , how in the aspx file do you tell it to do so?)
Posted 11-Jan-13 20:13pm
AU Jase651
Updated 11-Jan-13 20:14pm
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try this

<asp:fileupload id="fileupload1" runat="server" onchange="showButton()" xmlns:asp="#unknown" />
<asp:button id="btnUpload" runat="server" text="Upload" style="display:none" xmlns:asp="#unknown" />


<script type ="text/javascript" >
        function showButton() {
            document.getElementById("<%=btnUpload.ClientID%>").style.display = "";
        }
    </script>
 
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Use

if (FileUpload1.hasfile==true)
{

// Your Statement//////////////
}
  Permalink  
Comments
Member 12915803 2-Feb-17 2:07am
   
i am getting error when i do this step any other solution for this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web03 | 2.8.171114.1 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100