Results 1 to 4 of 4

Thread: Trying to disable an HtmlIntputFile Control

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Location
    Barcelona
    Posts
    70

    Trying to disable an HtmlIntputFile Control

    Hi,

    How can I disable an HtmlInputFile Control so that is not posted back when user submit the form?

    I tried this:
    Code:
    Sub on_Button2_Click(Sender As Object, E As EventArgs)
    
    image_path_QA.Disabled = True
    ...
    
    End Sub
    
    
    ...
    
                <td><input type="file" id="image_path_QA" runat="server" size="15" /></td>
    
    ...
    But it doesn’ t work, the file is posted back and the server ‘waits’ until the file added is totally uploaded. How can I ignore the control in the ‘on_Button2_Click’ subroutine?

    Thanks

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Trying to disable an HtmlIntputFile Control

    Surely if the file is uploaded then you should be directing the user to another page anyway?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Re: Trying to disable an HtmlIntputFile Control

    I have a page that upload an image shows it and allows the user to upload another image.....

    But, I don't understand why you would have a file upload field and not want the file to upload....

    anyway add the attrib onclick="return false;" do this via code when you want it to not work. that makes the button not fire. now if they type in a file....... maybe onkeypress="return false;"......
    Magiaus

    If I helped give me some points.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Location
    Barcelona
    Posts
    70

    Re: Trying to disable an HtmlIntputFile Control

    Hi,

    I want to do this when user presses a button to go back to previous form page. In that case, I don' t want to upload any file added, only I want to upload when the user presses another button to confirm the whole form page and to finalize the process.

    I found a solution with javascript.

    This is the code I used:
    Code:
     ‘ ASP.NET code here
    
    <html>
    <head>
    <script type="text/javascript">
    
       function disable_image_pathQA() {
    
         document.form2_newOffer.image_path_QA.disabled = true;
    
       }
    
    </script>
    
    </head>
    <body>
    
    <form runat=”server”>
    
    ‘ Code here
    
    <asp:button id=”go_back” onClick="update_data_back" onmouseup=”return disable_image_pathQA()” runat=”server” Text=”Go Back” />
    <asp:button id=”go_forward” onClick="update_data_forward" onmouseup=”return validate_form()” runat=”server” Text=”Go Forward” />
    
    
    </form>
    </body>
    </html>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width