Hi,
This is my understanding from your description.
You have
1.Master page say Masterpage.master
2.Mainmenu custom control on the master page. Say mainmenu.ascx
3.A login.aspx and and home.aspx
Try putting your code in mainmenu.ascx.cs file for enabling and disabling you menu according to the users.
And for the error, check whether the class file inherits the master page with the main menu.
See the below code for page declaratives and this works abolutely fine for me.
Page declarative of master
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="myMasterPage.master.cs" Inherits="myMasterPage" %>
<%@ Register TagName="myMainMenu" Src="~/myMainMenu.ascx" %>
Page declarative of home page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home"
MasterPageFile="~/myMasterPage.master" %>
<%@ MasterType VirtualPath="~/myMasterPage.master" %>
Page declarative of mainmenu
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MainMenu.ascx.cs" Inherits="MainMenu" %>
In your case, as the lanuguage is VB.You will have VB there.
For comparing your session variable for role, please see that the if condition first checks for the not null/nothing and the session value.
Hope this helps.