代码之家  ›  专栏  ›  技术社区  ›  Tom

显示在内容页上的母版页中的字符串

  •  0
  • Tom  · 技术社区  · 14 年前

    我试图在母版页中设置的内容页上显示一个字符串,但收到错误消息: “compid”不是“ASP.test\u master”的成员

    这是我的母版页代码:

    <%@ Master Language="VB" debug="true"  %>
    <script runat="server">
        Dim compid As String = "test"
    </script>
    <html>
    <head></head>
    <body>
    <asp:ContentPlaceHolder id="CPHLoginButton" runat="server" />
    </body>
    </html>
    

    以及我的内容页代码:

    <%@ Page Language="VB" MasterPageFile="test.master" %>
    <%@ MasterType virtualpath="~/test.master" %>
    
    <asp:Content ContentPlaceHolderId="CPHLoginButton" runat="server">
        <%= Master.compid %>
    </asp:Content>
    

    有什么想法吗?

    2 回复  |  直到 14 年前
        1
  •  1
  •   Waqas    14 年前

    可能是因为默认的访问修饰符。你的问题可以通过把compid公之于众来解决 Public compid As String = "test"

        2
  •  0
  •   Hps    14 年前

    您还可以尝试以下操作:

    <%= (Me.Master as test).compid %>