2010-11-25 33 views
0

我試圖在母版頁中設置的我的內容頁上顯示一個字符串,但我收到錯誤消息:'compid'不是'ASP .test_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> 

任何想法?

回答

1

它可能是因爲默認訪問修飾符。您的問題可以通過使compid公共somethign等解決了這個Public compid As String = "test"

0

您也可以嘗試以下方法:

<%= (Me.Master as test).compid %> 
相關問題