Tom
Tom

Reputation: 12998

String from master page displayed on content page

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?

Upvotes: 0

Views: 123

Answers (2)

Hps
Hps

Reputation: 1177

You can also try the following:

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

Upvotes: 0

Waqas
Waqas

Reputation: 6802

Its probably becuase of default access modifier. Your problem can be solved by making compid public somethign like this Public compid As String = "test"

Upvotes: 1

Related Questions