0
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. 
tfj

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

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

            <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>

            <div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
                    <Items>
                        <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>
                            <asp:MenuItem Text="View Violations" Value="View Violations">
                            </asp:MenuItem>
                        </asp:MenuItem>
                        <asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
                    </Items>
                </asp:Menu>
            </div>

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

        2014 

    </div>
    </form>
</body>
</html>
2
Contributors
1
Reply
31
Views
3 Years
Discussion Span
Last Post by taersious
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.