Not declared or inaccessible due to protection levels - VS 2017 errors
-
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!
-
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!
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
-
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
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.
-
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.
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 theCodeFile
orInherits
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
-
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 theCodeFile
orInherits
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
That's now working fine, Richard, many thanks.