zoukankan      html  css  js  c++  java
  • 从内容页设置母版页中控件的属性

    Site1.Master

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="Lib.Site1" %>

    <!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">
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
            <div class="page">
                <asp:Menu ID="VisitorMenu" runat="server" />
            </div>
        </form>
    </body>
    </html>

    Site1.Master.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace Lib
    {
        public partial class Site1 : System.Web.UI.MasterPage
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            public Menu theVisitorMenu
            {
                get { return VisitorMenu; }
                set { VisitorMenu = value; }
            }
    
        }
    }
    

     homepage.aspx

    <%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="homepage.aspx.cs" Inherits="Lib.homepage" %>
    <%@ MasterType VirtualPath="~/Site1.master" %> <!--关键,也有设置TypeName的,h ttp://msdn.microsoft.com/zh-cn/library/ms228274(VS.80).aspx-->

    <asp:Content ID="HeaderContent" ContentPlaceHolderID="head" runat="server">
    </asp:Content>

    <asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    </asp:Content>

    homepage.aspx.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace Lib
    {
    public partial class homepage : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    this.Master.theVisitorMenu.Visible = true;
    }
    }

    }
    }




    /**************************************************************************
                      原文来自博客园——Submarinex的博客: www.cnblogs.com/submarinex/               
      *************************************************************************/

  • 相关阅读:
    The Dfferents between Redirect and Forward锻炼英文水平
    在Asp.net中将GridView打印为word或者Excel
    oracle数据无法导入表情况之一
    对“不是内部或外部命令,也不是可运行的程序?”处理
    想去 2008 北京 sun 科技日
    Bad version number in .class file
    Applet问题
    KTV
    命令行下的mysql的基本操作
    Ajax之DWR框架使用小结(2)
  • 原文地址:https://www.cnblogs.com/submarinex/p/2296570.html
Copyright © 2011-2022 走看看