Hi I have just upgraded a project from 2005 net 2.0 frame work to 2008
net 3.5 frame work
On the (single not nested) master page I have a lable which is wrapped
in a public sub to set its text and fore colour
The content pages which inherit from the master page do not now see
the public sub and give a compile error
I've deleted the sub saving the project and adding the public sub back
again - no joy
How do I declare a sub of a master page which is visible to the conten
pages please?
Mark Rae [MVP] - 27 Apr 2008 17:53 GMT
> The content pages which inherit from the master page
The content pages inherit from the MasterPage?
> do not now see the public sub and give a compile error
And what is the compile error?
> How do I declare a sub of a master page which is visible to the content
> pages please?
Have you forgotten to reference the Master Page through the Page.Master
property or set the @MasterType directive in the aspx file...?

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
Fernando Rodriguez - 27 Apr 2008 18:23 GMT
I may be confused, but Content pages do not inherit from Master pages, not
even in 2.0. To access a method on the master page from you content page you
need to do use the Master property on the content page, which will return an
instance of your master page that you need to cast to the actual type of
your master page before you can call the method (actually VB may let you
call it without casting but in order to see it on intellisense you need to
cast it as follows:
If TypeOf Me.Page.Master Is MyMasterPageType Then
CType(Me.Page.Master, MyMasterPageType).MyPublicMethod()
End If
If that's not what you're trying to do please post some code samples so I
can get a better idea.
Hope that helps,
Fernando Rodriguez
> Hi I have just upgraded a project from 2005 net 2.0 frame work to 2008
> net 3.5 frame work
[quoted text clipped - 8 lines]
> How do I declare a sub of a master page which is visible to the conten
> pages please?
Ex glider pilot - 25 May 2008 17:06 GMT
On Apr 27, 6:23 pm, "Fernando Rodriguez"
<frodrig...@mcp.microsoft.com> wrote:
> I may be confused, but Content pages do not inherit from Master pages, not
> even in 2.0. To access a method on the master page from you content page you
[quoted text clipped - 29 lines]
>
> - Show quoted text -