KB Issue
Why am I receiving the error, 'It might be inaccessible due to its protection level'?
Issue 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.
Several scenarios can cause this error. In this article, we will only list them as we experience the error and correct them on our end.
Recreate Issue
Scenario #1 and #2
When the component's name is [ID].
<asp:Label ID="ID" runat="server" Text="Label"></asp:Label>
Copy
Search Site
Search Google

CodeFile is
VB.NET
ID.Text = "Page set to Upload!"
Copy
Search Site
Search Google

C#
ID.Text = "Page set to Upload!";
Copy
Search Site
Search Google
Resolve Issue
[Scenario #1]
(Working in a Visual Studio Project)
In the above example, we see the ID is named [ID]. However, the "ID" name has changed.
The new name is now [IDLabel] as demonstrated here.
<asp:Label ID="IDLabel" runat="server" Text="Label"></asp:Label>
Copy
Search Site
Search Google

But the name has not been updated in the Test.aspx.designer.vb or Test.aspx.designer.cs
[ASP.NET - Test.aspx.designer.vb]
For VB.NET, the Test.aspx.designer.vb will look like this.
VB.NET
CFFCS | CarrzSynEdit: | ASP.NET (VB/C#)
Partial 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

[ASP.NET - Test.aspx.designer.cs]
For C#, the Test.aspx.designer.cs will look like this.
CFFCS | CarrzSynEdit: | ASP.NET (VB/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}

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
Copy
Search Site
Search Google

C#
protected global::System.Web.UI.WebControls.Label IDLabel;
Copy
Search Site
Search Google
Making the list of components looks like this.
[ASP.NET - Protected WithEvents IDLabel]
VB.NET
CFFCS | CarrzSynEdit: | ASP.NET (VB/C#)
Partial 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

[ASP.NET - protected global IDLabel]
C#
CFFCS | CarrzSynEdit: | ASP.NET (VB/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!"
Copy
Search Site
Search Google

C#
IDLabel.Text = "Page set to Upload!";
Copy
Search Site
Search Google
[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!"
Copy
Search Site
Search Google

C#
ID.Text = "Page set to Upload!";
Copy
Search Site
Search Google

to
VB.NET
IDLabel.Text = "Page set to Upload!"
Copy
Search Site
Search Google

C#
IDLabel.Text = "Page set to Upload!";
Copy
Search Site
Search Google

To match our component ID name.
<asp:Label ID="IDLabel" runat="server" Text="Label"></asp:Label>
Copy
Search Site
Search Google