views:

660

answers:

3

I have masterpage.master.vb where I have properties, such as;

 Private _SQLerror As String
    Public Property SQLerror() As String
        Get
            Return _SQLerror
        End Get
        Set(ByVal value As String)
            _SQLerror = String.Empty

        End Set
    End Property

Then I have an aspx page in which I need to use this property in, such as;

 If **[masterpage property sqlerror]** = Nothing Then
            InternalSQLErrLabel.Text = ("No Errors Reported")
        End If

Can anyone give me an idea how to go about this? I've tried searching but most articles talk in the context of web controls...

Thanks.

+1  A: 
Andy West
Thats what I was trying before asking my question, but with no luck! ... i get; SQLError is not a member of system.web.ui.masterpage.
Phil
Did you add the MasterType directive? It looks like that might be your problem. The Master property is not strongly typed, so it is of type System.Web.UI.MasterPage, which does not have your property.
Andy West
I have <%@ MasterType VirtualPath="~/my.master”" %> and in @page MasterPageFile="~/my.master"
Phil
I built a test Web site to show that this works. Have a look. Not much more I can do than that.
Andy West
Thats really helpful thanks a lot. Ive now got it working and marked you as the best answer. Phil.
Phil
You're welcome, glad it helped.
Andy West
A: 

Hi, you can cast the masterpage to the correct type:

MyMasterPageType m = (MyMasterPageType)Master;

Then you can access your properties:

m.SqlError

If you have multiple master pages, let all your masterpages inherit from an interface, and cast the masterpage to that interface.

Best regards, -- Rob.

daRoBBie
A: 

You can use <%@ MasterType %> also for this.

Dimuthu