error BC30451: 'xxxx' is not declared. It may be inaccessible due to its protection level

I've converted an app from a previous version of VS and i'm getting tons of errors like this:
"error BC30451: 'xxxx' is not declared.  It may be inaccessible due to its protection level"

This code is inside a "ContentPlaceHolder" because this page is using a master file.
Here's a sample of code saying that UserListGrid is not declared.
(in ListUser.aspx)
<asp:Content ID="Content2" ContentPlaceHolderID="Contenu" Runat="Server">
<div id="contenu">
    <table bgcolor="#000000" border="0" width=100% cellspacing=0 cellpadding=0>
    <tr height="25"><td valign="middle">
    <div style="font-weight:bold; font-size:x-large; color:#FFFFFF;margin:5px 0 5px 0; text-align:center">
        <asp:Label ID="UserList" runat="server" Text="LISTE DES USAGERS" meta:resourcekey="TitleGridUserList"></asp:Label>
    </div>
    </td></tr>
    </table>
    <asp:GridView ID="UserListGrid" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None"
        BorderWidth="1px" CellPadding="4" DataSourceID="dsUserList" ForeColor="Black"
        GridLines="Vertical" width=100% DataKeyNames="UserName,UserId" 
        OnSelectedIndexChanged="SelectedUser" meta:resourcekey="GridUserList">
...

Open in new window


(in ListUser.aspx.vb)
Public Sub SelectedUser(ByVal sender As Object, ByVal e As System.EventArgs)
        ' *****************************************************************************
        ' Sub SelectedUser
        '
        ' When an administrator select a user in the Users List, it trigger this function.
        ' It will fill the Drop Down List containing Roles properly by showing only Roles
        ' that this user doesn't yet.
        ' *****************************************************************************
        Dim sID, sUser As String

        If UserListGrid.SelectedRow IsNot Nothing Then
            Try
                sUser = UserListGrid.SelectedRow.Cells(IDX_COL_USERNAME).Text       ' Get the UserName for the selected user
                sID = UserListGrid.SelectedDataKey.Values(1).ToString()             ' Get the UserID for the selected user

                ' If there's a valid Guid, we modify the query to refresh the Drop Down List
                If sID <> "" Then
                    dsNewRole.SelectCommand = "SELECT * FROM vw_aspnet_Roles WHERE RoleId not In (SELECT RoleId FROM vw_aspnet_UsersInRoles WHERE UserId = '" & sID & "')"
                End If
            Catch ex As Exception
                ' Should place error trapping code here
            End Try

        End If
    End Sub

Open in new window



Thanks for your help
LVL 10
Christian de BellefeuilleProgrammerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Miguel OzSenior Software EngineerCommented:
Please post your all master page and content page.

I want to check if:
1) Your code has a proper construct, like:
http://www.w3schools.com/aspnet/aspnet_masterpages.asp
2) If your code has name collissions, meaning fileds named as  your gridview id, etc.

Note: if you can tell us form which version you convert your code from.
CodeCruiserCommented:
From what version to what? VS2010 introduced the .designer files for asp.net so that may be the reason behind these errors. How did you upgrade?
Christian de BellefeuilleProgrammerAuthor Commented:
The code was originally written using VS2005.  

And i want to mention that the object UserListGrid is visible from the code behind of the content page!  I can type "Me." then intellisense show UserListGrid.  I also can see it from the top DropDown menu to set one of its event.

I cannot post the whole code here for privacy & security purpose.  

The whole master page is here:
 
<%@ Master Language="VB" CodeFile="Facilis.master.vb" Inherits="Facilis_secure_Facilis" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Facilis Conference Secured Zone</title>
    <link href="/Secure/css/screen.css" type="text/css" rel="stylesheet" />   
</head>

<body>
<form id="Facilis" runat="server">
    <div id="contenant">                  
        <table width=1000px bgcolor="black" style="color:White" height="70">
            <tr>
                <td><img src="/Secure/images/logo_facilis_mini.jpg" alt="Facilis" width="112" height="50" /></td>
                <td>
                    <asp:LoginView ID="LoginView2" runat="server">
                        <AnonymousTemplate>
                            <asp:Login ID="Login1" runat="server" BorderStyle="None" BorderWidth="0px"  Font-Names="Verdana" Font-Size="10pt" Orientation="horizontal">
                                <LayoutTemplate>
                                    <asp:TextBox ID="UserName" runat="server"  style="font-size:larger; color:white; padding-top:13px; text-align:center;background-image:url(/Secure/images/obj_username.jpg);z-index:2; width:188px; height:45px; background-repeat:no-repeat" BackColor="Transparent" BorderWidth="0px" Height="45px" Width="188px"></asp:TextBox>
                                    <asp:TextBox ID="Password" runat="server" TextMode="Password"  style="font-size:larger; color:white; padding-top:13px; text-align:center;background-image:url(/Secure/images/obj_password.jpg);z-index:2; width:188px; height:45px; background-repeat:no-repeat" BackColor="Transparent" BorderWidth="0px" ></asp:TextBox>
                                    <asp:Button ID="LoginButton" runat="server" CommandName="Login" style="vertical-align:top; margin-top:1px; background-image:url(/Secure/images/obj_login.jpg);z-index:2; width:188px; height:45px; background-repeat:no-repeat" BackColor="Transparent" BorderWidth="0px" ValidationGroup="ctl00$Login1" />
                                    <asp:CheckBox ID="RememberMe" runat="server" style="vertical-align:top" Text="Remember me next time." ForeColor="White" /><asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                                </LayoutTemplate>
                            </asp:Login>                            
                            <asp:Label ID="CreerUsager" runat="server" Text="Vous n'avez pas de compte?"></asp:Label> <asp:LinkButton ID="btnCreateUser" runat="server" PostBackUrl="~/Secure/SecurityLevels/Anonymous/CreateUser.aspx">Créez votre compte.</asp:LinkButton>&nbsp;
                        </AnonymousTemplate>
                        
                        <LoggedInTemplate>
                            Bonjour <asp:LoginName ID="LoginName1" runat="server" />! (<asp:LoginStatus ID="LoginStatus1" runat="server" />)
                            <asp:Menu ID="mnuTop" runat="server" Orientation="horizontal" DataSourceID="SiteMapDataSource1" BackColor="Black" BorderColor="Transparent" Font-Bold="True" Font-Names="Arial" Font-Overline="False" Font-Size="Medium" Font-Strikeout="False" Font-Underline="True" ForeColor="DarkKhaki" Height="50px" Width="100%" DynamicHorizontalOffset="10" >
                                <DynamicHoverStyle BackColor="#A39C6E" ForeColor="Black" Font-Size="Small" Font-Underline="True" />
                                <DynamicMenuStyle BackColor="#D3CC9E" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" HorizontalPadding="10px" VerticalPadding="10px" />
                                <DynamicMenuItemStyle Font-Size="Small" ForeColor="Black" />
                                <StaticHoverStyle ForeColor="#BBBF8C" />
                            </asp:Menu>
                        </LoggedInTemplate>                        
                    </asp:LoginView>
                </td>
            </tr>
        </table>
         
        <asp:ContentPlaceHolder  ID="Contenu" runat="server" />


    </div>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="False" />
</form>
</body>
</html>

Open in new window


The Master code behind is here (it contain nothing yet):
 
Partial Class Facilis_secure_Facilis
    Inherits System.Web.UI.MasterPage
End Class

Open in new window


OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Christian de BellefeuilleProgrammerAuthor Commented:
@CodeCruiser: I've just tried to open the solution... but i did that long time ago and didn't checked at the result.  
Miguel OzSenior Software EngineerCommented:
I think your issue is name clashing in your content page, notice that:
<asp:Content ID="Content2" ContentPlaceHolderID="Contenu" Runat="Server">
<div id="contenu">

You are using contenu as your id for both the div and ContentPlaceHolder. Replace these lines with:
<asp:Content ContentPlaceHolderID="Contenu" Runat="server">
<div id="contentmain">

Note: If this does not solve your problem I need the content page code. (I do not need the code behind but the class declaration, regarding markup, just leave the gridview and associated source on the markup code)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Christian de BellefeuilleProgrammerAuthor Commented:
That's what i thought when i compiled that on VS2005, it worked perfectly.  On 2010, it fail.
Also, the DIV is not accessible as an object since it's not an ASP label with "Runat=Server" so the name shouldn't be a problem.

But i did the test... i've renamed "div" named "Contenu" for "Contenu2222" (no where in my code i try to access to this item, or do any FindControl in my code behind file).  Same result...

The part which intrigue me is the "may be inaccessible due to its protection level.".  I've not found any property giving me the opportunity to change the protection level in an asp:GridView (or any other asp object).  

My class is declared "Partial class TheNameOfTheClass" (as usual), it inherits from System.Web.UI.Page as it should.  My classes using the UserListGrid is "Public".  Do i have to switch that to private or anything else?
Christian de BellefeuilleProgrammerAuthor Commented:
I'm using Visual Source Safe for my "versionning", and apparently this is causing the problem.  I'm not going to dig deeper to find what's the cause of the problem, but when i take my code out of the VSS, it work perfectly.

Since i'm the only person who work on that web site, i'll just keep my source out of VSS for the moment and keep backups of each versions manually.

Thanks for your help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.