How to make the other control visible

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cmrhema
    Contributor
    • Jan 2007
    • 375

    How to make the other control visible

    Hi
    I have a fileupload control in asp.net and another normal button.

    What I want to do is I want the Normal Button to be enabled only after the files has been chosen in the FileUpload control.

    Can anyone help me please


    regards
    cmrhema
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    You can check if files has beed selected or not into FileUpload control using FileName property.
    e.g.

    ''Check if file is selected for uploading

    If FileUpload1.Fil eName <> "" Then
    ''Write code to enable button
    End If

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by cmrhema
      Hi
      I have a fileupload control in asp.net and another normal button.

      What I want to do is I want the Normal Button to be enabled only after the files has been chosen in the FileUpload control.

      Can anyone help me please


      regards
      cmrhema
      You are going to have to have a bit of JavaScript check to see if anything has been provided by the user.

      I would create a function that would be executed on the FileUpload's "onchange" JavaScript event:

      eg:
      [code=vbnet]
      myPhotoUpload.A ttributes.Add(" onchange","Enab leUploadButton( '" + myUploadButton + "')")
      [/code]

      Where the JavaScript function "EnableUploadBu tton" would resemble something like:
      [code=JavaScript]
      function EnableUploadBut ton(idOfButton)
      {
      var button = document.getEle mentByID(idOfBu tton).disabled = false;
      }
      [/code]

      You will have to set your upload button to be initially rendered in the browser as "disabled".

      Cheers!

      -Frinny

      Comment

      • cmrhema
        Contributor
        • Jan 2007
        • 375

        #4
        Originally posted by Frinavale
        You are going to have to have a bit of JavaScript check to see if anything has been provided by the user.

        I would create a function that would be executed on the FileUpload's "onchange" JavaScript event:

        eg:
        [code=vbnet]
        myPhotoUpload.A ttributes.Add(" onchange","Enab leUploadButton( '" + myUploadButton + "')")
        [/code]

        Where the JavaScript function "EnableUploadBu tton" would resemble something like:
        [code=JavaScript]
        function EnableUploadBut ton(idOfButton)
        {
        var button = document.getEle mentByID(idOfBu tton).disabled = false;
        }
        [/code]

        You will have to set your upload button to be initially rendered in the browser as "disabled".

        Cheers!

        -Frinny
        Many Thanks Frinnvale, it works now

        Comment

        Working...