Good Afternoon.

I submitted a question a couple of days ago under the article name: 
    Change asp:menuitem properties from other programs.

I'm working with the following web pages - 
    Site.Master/Site.Master.vb, Login.aspx/Login.aspx.vb

JorgeM answered my question and showed me the code to use.  It worked great.  

    Dim navMenu As Menu
    navMenu = CType(Master.FindControl("NavigationMenu"), Menu)
    navMenu.Items.Item(2).Selectable = False

So, I added 2 more controls using the same type of code:

    Dim WelcomeLabel As New Label
    WelcomeLabel = CType(Master.FindControl("WelcomeLabel"), Label)
    WelcomeLabel.Text = "Welcome " & OLEdr.Item("ho1FirstName")

    Dim LogHyperlink As New HyperLink
    LogHyperlink = CType(Master.FindControl("LogHyperlink"), HyperLink)
    LogHyperlink.Text = "Log Out"
    LogHyperlink.NavigateUrl = "Exit.aspx"

They work as well.

The above code resides in Login.aspx.vb. However, I didn't realize until today 
that the code works temporarily.  It does what it is suppose to do but when
I navigate to another page, say About.aspx, thru the menu items, the Site.Master
page is back to the orginal and I have lost the changes the code made.

Is it possible to make the changes permanent for the session?

Thank you. 

<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site.master.vb" Inherits="SunriseFarms.Site" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" xml:lang="en">
<head id="Head1" runat="server">
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    <style type="text/css">
            font-size: medium;
    <form id="Form1" runat="server">
    <div class="page">
        <div class="header">
            <div class="title">
                    Sunrise Farms <span class="style1">Homeowner&#39;s Association</span>

            <div class="loginDisplay">
                <asp:Label ID="WelcomeLabel" runat="server" Text=""></asp:Label>
                <asp:HyperLink ID="LogHyperlink" navigateurl="~/Account/Login.aspx" runat="server">Log In</asp:HyperLink>

            <div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home" Selected="True"/>
                        <asp:MenuItem NavigateUrl="SFDR.pdf" Text="Declaration of Restrictions" 
                            Value="Declaration of Restrictions"></asp:MenuItem>
                        <asp:MenuItem NavigateUrl="~/HOADues.aspx" Text="HOA Dues" Enabled="True"/>
                        <asp:MenuItem NavigateUrl="" Text="Violations">
                            <asp:MenuItem Text="Report A Violation" Value="Report A Violation">
                            <asp:MenuItem Text="View Violations" Value="View Violations">
                        <asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>

        <div class="main">
            <asp:ContentPlaceHolder ID="MainContent" runat="server"/>
        <div class="clear">
    <div class="footer">



You would need to place this logic in every page which needs this funcionality. A better option would be to move this logic to your Site.Master.vb file and allow the MasterPage to control this funcitonality. This way you would not be repeating the code in each page, which it one of the purposes of having a MagerPage in the first place.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.