#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Visible/Invisible labels?


    Hello

    I have a vb.net (Visual Studio 2013 Express for Web) file that allows the user to upload files to the server.

    When the user gains access to that page having logged-in, he should see the following message: 'Please upload your file(s)'

    If, however, he presses the 'Upload' button by mistake - without choosing a file to upload - he should see: 'You have not specified a file' and the 'Please upload your file(s) text should no longer be visible at that point.

    In my particular case, the 'Please upload your file(s)' message is not visible at all when the user first visits the page, and if I click 'Upload' without selecting a file, the 'You have not specified a file' message does not appear - nothing does.

    What am I doing wrong, please? This is the code I have:

    Code:
    Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
    
            Label2.Text = "Please upload your file(s)"
    
            Label3.Visible = False
    
            If MyFileUpload.HasFile Then
                Try
                    MyFileUpload.SaveAs("C:\Uploads\" & _
                        MyFileUpload.FileName)
                    Label3.Text = "File name: " & _
                        MyFileUpload.PostedFile.FileName & "<br>" & _
                        "File Size: " & _
                        MyFileUpload.PostedFile.ContentLength & "<br>" & _
                        "Content type: " & _
                        MyFileUpload.PostedFile.ContentType & "<br>" & _
                        "Location Saved: C:\Uploads\" & _
                        MyFileUpload.FileName
                Catch ex As Exception
    
                    Label4.Text = "ERROR: " & ex.Message.ToString()
                End Try
            Else
                Label3.Text = "You have not specified a file."
    
                Label2.Visible = False
    
            End If
    
        End Sub
    In my aspx file, I have:

    Code:
     <asp:Label ID="Label2" runat="server" Text="" CssClass="upload"></asp:Label><br />
    
    <asp:Label ID="Label3" runat="server" Text="" CssClass="error"></asp:Label><br />
    
    <asp:Label ID="Label4" runat="server" Text="" CssClass="FileName"></asp:Label><br />
    Thank you for any help.

    Blue
  2. #2
  3. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Aug 2008
    Location
    USA
    Posts
    1,606
    Rep Power
    348
    Your code looks good to me.

    Please see this example for your more help.

    code:
    QuickStarts Source Control Viewer

    example :
    http://quickstarts.asp.net/quickstar...pload1_vb.aspx
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree

    Jquery Shake Effect ,
    Andriod KitKat


    Thank You,
    KiranK
  4. #3
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0
    Hello Mark

    Many thanks for your reply and links.

    Yes, that's what I mean.

    It is not at all clear how I can add kudos to your post.

    Thanks again and sorry for the delay in replying.
  6. #4
  7. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Aug 2008
    Location
    USA
    Posts
    1,606
    Rep Power
    348
    Thanks for your comments.. Glad to help you

    Happy coding

Similar Threads

  1. Invisible label still visible after history.back
    By stanleyeng in forum .NET Development
    Replies: 3
    Last Post: March 30th, 2012, 07:54 PM
  2. Language Can Make the Invisible Visible (LiveScience.com)
    By RSS_News_User in forum Science News
    Replies: 0
    Last Post: July 13th, 2010, 11:00 PM
  3. Making data visible or invisible in a form?
    By db_man in forum Microsoft Access Help
    Replies: 5
    Last Post: February 16th, 2007, 07:35 PM
  4. List visible and invisible
    By He_ba in forum .NET Development
    Replies: 6
    Last Post: April 22nd, 2006, 06:27 AM
  5. Visible / invisible text field
    By jabez in forum Microsoft Access Help
    Replies: 7
    Last Post: January 21st, 2006, 11:41 PM

IMN logo majestic logo threadwatch logo seochat tools logo