CFF KB - Carrz-Fox-Fire Promotions Knowledge Base
CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.Knowledge Base
- Breadrumbs:
BC30451: 'xxxxxx' is not declared. It might be inaccessible due to its protection level.
- Article ID:
6255 - Date Created
Thursday, June 16, 2022 - Last Updated
Thursday, June 16, 2022 - This Article Has been Viewed
763 times - Short Desc
Why am I receiving the error, 'It might be inaccessible due to its protection level'? - Details
IN ASP.NET, changing component names can sometimes cause the component not to be updated. If this happens you will experience the following error.BC30451: 'IDLabel' is not declared. It might be inaccessible due to its protection level.
There are different scenarios that can cause this error to appear. In this article, we will only list them as we experience the error and correct them on our end. We will not take information from online sources and post it as our own errors. - Recreate Issue
Scenario #1 and #2
#1 Working in a Visual Studio Project
#2 Working on a Visual Studio Website
When the components name is ID.
(Ignore the open and closing brackets in these examples)<%
<asp:Label ID="ID" runat="server" Text="Label"></asp:Label>
%>
CodeFile is
VB.NET
ID.Text = "Page set to Upload!"
C#
ID.Text = "Page set to Upload!"; - Resolve Issue
Scenario #1
(Working in a Visual Studio Project)
In the above example, we see the ID is named [ID]. However, the name of the ID has changed.
The new name is now IDLabel as demonstrated here.<%
<asp:Label ID="IDLabel" runat="server" Text="Label"></asp:Label>
%>
But the name has not been updated in the Test.aspx.designer.vb or Test.aspx.designer.cs
For VB.Net the Test.aspx.designer.vb will look like this. (Comments removed for space)
VB.NETPartial Public Class Size
Protected WithEvents form1 As Global.System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents fuUpload As Global.System.Web.UI.WebControls.FileUpload
Protected WithEvents btnUpload As Global.System.Web.UI.WebControls.Button
End Class
For C# the Test.aspx.designer.cs will look like this.Partial Public Class Size{
protected global::System.Web.UI.WebControls.HtmlForm form1;
protected global::System.Web.UI.WebControls.FileUpload fuUpload;
protected global::System.Web.UI.WebControls.Button btnUpload;
protected global::System.Web.UI.WebControls.Label IDLabel;
End Class}
To correct the issue, we need to add the IDLabel to the list of components used by our project.
VB.NET
Protected WithEvents IDLabel As Global.System.Web.UI.WebControls.Label
C#
protected global::System.Web.UI.WebControls.Label IDLabel;
Making the list of components looks like this.
VB.NETPartial Public Class Size
Protected WithEvents form1 As Global.System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents fuUpload As Global.System.Web.UI.WebControls.FileUpload
Protected WithEvents btnUpload As Global.System.Web.UI.WebControls.Button
Protected WithEvents IDLabel As Global.System.Web.UI.WebControls.Label
End Class
C#Partial Public Class Size{
protected global::System.Web.UI.WebControls.HtmlForm form1;
protected global::System.Web.UI.WebControls.FileUpload fuUpload;
protected global::System.Web.UI.WebControls.Button btnUpload;
protected global::System.Web.UI.WebControls.Label IDLabel;
End Class}
Then in our CodeFile
VB.NET
IDLabel.Text = "Page set to Upload!"
C#
IDLabel.Text = "Page set to Upload!";
Scenario #2
(Working on a Visual Studio Website)
When working on a website project, you will not have the Test.aspx.designer.vb or Test.aspx.designer.cs files. Instead, you will need to update the ID name in the CodeFile.
VB.NET
ID.Text = "Page set to Upload!"
C#
ID.Text = "Page set to Upload!";
to
VB.NET
IDLabel.Text = "Page set to Upload!"
C#
IDLabel.Text = "Page set to Upload!";
To match our component ID name.<%
<asp:Label ID="IDLabel" runat="server" Text="Label"></asp:Label>
%>
Share With Friends (Updated 6-8-2010)
Recent Articles
All Topics
- Coming Soon - Knowledge Exchange
Trending Articles
- Microsoft VBScript runtime error '800a0046' Permission denied FileSystemObject 24695
- Microsoft OLE DB Provider for SQL Server error '80040e57' String or binary data would be truncated. or The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. 21297
- ADODB.Parameters error '800a0e7c' Parameter object is improperly defined 19544
- After Effects warning: Audio conforming failed for the following file .cfa. Perhaps due to disk space 17785
- The backup set holds a backup of a database other than the existing 16825