内容页上显示的母版页中的字符串
我试图在母版页中设置的内容页上显示一个字符串,但收到错误消息: '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>
有什么想法吗?
I'm trying to display a string on my content page which is set in the master page but i'm getting the error message: 'compid' is not a member of 'ASP.test_master'
Here's my master page code:
<%@ 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>
And my content page code:
<%@ Page Language="VB" MasterPageFile="test.master" %>
<%@ MasterType virtualpath="~/test.master" %>
<asp:Content ContentPlaceHolderId="CPHLoginButton" runat="server">
<%= Master.compid %>
</asp:Content>
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能是因为默认的访问修饰符。您的问题可以通过将 compid 设为公共来解决,如下所示
Public compid As String = "test"
Its probably becuase of default access modifier. Your problem can be solved by making compid public somethign like this
Public compid As String = "test"
您还可以尝试以下操作:
You can also try the following: