Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Not declared or inaccessible due to protection levels - VS 2017 errors

Not declared or inaccessible due to protection levels - VS 2017 errors

Scheduled Pinned Locked Moved ASP.NET
visual-studioquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 8761667
    wrote on last edited by
    #1

    Hello

    I am just wondering why, if I have these lines of code in my aspx file

    why I would get the following red underlined errors (VS 2017) in my corresponding aspx.vb file:

    pnlFormFields.Visible = False
    pnlThankYouMessage.Visible = True
    LblDate.Text = ReturnDate()

    Not declared or inaccessible due to protection levels.

    What should I have, please?

    Thanks!

    Richard DeemingR 1 Reply Last reply
    0
    • M Member 8761667

      Hello

      I am just wondering why, if I have these lines of code in my aspx file

      why I would get the following red underlined errors (VS 2017) in my corresponding aspx.vb file:

      pnlFormFields.Visible = False
      pnlThankYouMessage.Visible = True
      LblDate.Text = ReturnDate()

      Not declared or inaccessible due to protection levels.

      What should I have, please?

      Thanks!

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      The most likely cause is that your controls are declared inside a data-bound control - FormView, GridView, ListView, etc.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      M 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        The most likely cause is that your controls are declared inside a data-bound control - FormView, GridView, ListView, etc.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        M Offline
        M Offline
        Member 8761667
        wrote on last edited by
        #3

        Thanks, Richard, for replying. I have this:

        Function ReturnDate() As String

        Code for ordinal date

        End Function

        And then:

        Protected Sub SendEmail_Click(sender As Object, e As System.EventArgs)

        SMTP code here

        End Sub

        And this, where the errors occur:

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            'user\_name.Focus()
        
            pnlFormFields.Visible = False
            pnlThankYouMessage.Visible = True
            LblDate.Text = ReturnDate()
        
        End Sub
        

        The forms tell the user 'thank you' when he clicks on 'Send' (the form), but I didn't think it would be part of the SMTP

        Protected Sub SendEmail_Click

        , and I didn't think the 'show date'would be part of the Date Function, so I put the three lines of code above (the ones with the errors) in that

        Protected Sub Page_Load

        . Thanks again.

        Richard DeemingR 1 Reply Last reply
        0
        • M Member 8761667

          Thanks, Richard, for replying. I have this:

          Function ReturnDate() As String

          Code for ordinal date

          End Function

          And then:

          Protected Sub SendEmail_Click(sender As Object, e As System.EventArgs)

          SMTP code here

          End Sub

          And this, where the errors occur:

          Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

              'user\_name.Focus()
          
              pnlFormFields.Visible = False
              pnlThankYouMessage.Visible = True
              LblDate.Text = ReturnDate()
          
          End Sub
          

          The forms tell the user 'thank you' when he clicks on 'Send' (the form), but I didn't think it would be part of the SMTP

          Protected Sub SendEmail_Click

          , and I didn't think the 'show date'would be part of the Date Function, so I put the three lines of code above (the ones with the errors) in that

          Protected Sub Page_Load

          . Thanks again.

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          As I said, the problem is most likely that your controls are part of a data-bound control. That's in the .aspx file, not the .aspx.vb file. The other option would be if the CodeFile or Inherits attributes on the <%@ Page ... %> directive don't match the code-behind file.


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          M 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            As I said, the problem is most likely that your controls are part of a data-bound control. That's in the .aspx file, not the .aspx.vb file. The other option would be if the CodeFile or Inherits attributes on the <%@ Page ... %> directive don't match the code-behind file.


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            M Offline
            M Offline
            Member 8761667
            wrote on last edited by
            #5

            That's now working fine, Richard, many thanks.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups