Home > DeveloperSection > Forums > Is there a way to check Fileupload has file or not in client side.If It has i want to enable button
Nattapong Unaregul
Nattapong Unaregul

Total Post:3

Points:21
Posted on    July-21-2012 12:02 AM

 VB.Net VB.Net 
Ratings:


 2 Reply(s)
 5803  View(s)
Rate this:
Here is my code in default.aspx .The default.aspx is in the content place
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table>
   <tr> <td><asp:FileUpload ID="FileUpload1" runat="server" " /></td>
           <td> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Task cannot be blank"
        InitialValue="" ControlToValidate="FileUpload1"> </asp:RequiredFieldValidator></td></tr>
   <tr><td><asp:Button ID="SaveBT" runat="server" Text="Button" Enable = "False"  /></td></tr> 
  </table>    
  

</asp:Content>




Arun Singh

Total Post:68

Points:476
Posted on    July-21-2012 12:58 AM


Modified On Mar-18-2016 06:14:21 AM

Nattapong Unaregul
Nattapong Unaregul

Total Post:3

Points:21
Posted on    July-22-2012 8:19 PM

Thank for your advice.Here is my solution

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:FileUpload ID="FileUpload1" runat="server" onchange="FileUpload_OnChange(this,event);"   />  &nbsp; &nbsp; &nbsp;
<table>
   <tr>  <td> <input type="button" value = "Preview" /></td> </tr> 
    </table>
    
    <script  language="javascript" type ="text/javascript" >
        function Alert(myButton) {
            alert(myButton)
}
            function changeColor(myButton) {
            myButton.value = "OK";
        }
        function FileUpload_OnChange(sender, e) {


            document.getElementById('<%=Button1.ClientID %>').disabled = false;
        }
    </script>
</asp:Content>

Modified On Mar-18-2016 06:14:49 AM

Don't want to miss updates? Please click the below button!

Follow MindStick